rendered paste body
Extrn GetDec:Far, PutDec$:Far, PutDec:Far, Putstrng:Far, NewLine:Far ;
#include "iostream.h"
Data Segment
;######Game variables###########
CASH dw 5551 ;cash in cents
DAY dw 1
GlassesSold dw ?
PriceperGlass dw 2
Income dw ?
Expenses dw ?
GlassesMade dw ?
AdvertisingMade dw ?
Profit dw ?
Assets dw ?
CurrentAssets dw ?
;######inputforday function prompts######
OnDay db "On day " ; length 7
LemonadeCost db ", The Cost of Lemonade is " ; length 26
;######Random number function vars######
RAND_k dw 369
RAND_seed dw ?
;######prompts#########
intro db "Welcome to lemonade stand" ;basic intro prompt 25
weather db 'Todays weather is' ;weather report 17
dailystatement db 'Lemonade stand Daily Statement:' ;daily statement 31
date db 'On day: ' ;day output
Data Ends
Code Segment
Assume Cs:Code, Ds:Data, Ss:Sseg
;#####Convert to Dollar#######
;takes 1 value converts it front cents
;to dollars
;Returns Whole # in Ax
;Cents # in DX
@CentstoDollars Proc Near C, @CASH:WORD
push Bx
xor dx,dx
mov Ax, @Cash
mov Bx, 100
iDiv Bx
pop Bx
ret
@CentstoDollars Endp
;#####random number generator#######
;gets a large number, a seed, and an upper limit
;seed is wiped out initially
;system time is used for seed
;answer is returned in Ax
@RANDOMNUMBER Proc Near C, K:WORD, seed:WORD, @high:word
push Bx
push Cx
push Dx
xor Ax, Ax ;clear AX
mov ah, 2Ch ;load 2Ch into ah
int 21h ;load system time into registers
mov seed, Dx ;dh holds seconds, dl holds ms, move to seed
mov ax, seed ;move seed to Ax
mul k ;multiply by large k
inc ax ;add 1
mov seed, ax ;put Ax into the seed
shr ax,1 ;shift logical right 1 place
mov bx, @high ;put high value into Bx
add bx, 5 ;add 5 to it
@loopit:
and ax, bx ;mask to 5+ax
mov bx, @high ;put high into bx
cmp al, bl ;is it high#?
ja @loopit ;loop till a number is chosen < high
pop Dx
pop cx
pop Bx
ret
@RANDOMNUMBER ENDp
;####ClearScreen######
;clears the screen with a loop
;puts @line # of new lines on the screen
@cLEARSCREEN Proc Near C, @lines:word
push Ax
push Bx
push Cx
push Dx
mov Bx, @lines
@CSfor: cmp bx, 0
ja @CSdo
jmp @CSendfor
@CSdo:
call newline
dec Bx
jmp @CSfor
@CSendfor:
pop Dx
pop Cx
pop Bx
pop Ax
ret
@CLEARSCREEN ENDp
@outputdollars Proc Near C, @money:word
invoke @CentstoDollars, @money
push Ax
push dx
xor ax, ax
xor dx, dx
mov ah, 02h
mov Dl, 36
int 21h
pop Dx
pop Ax
call putdec$
push Ax
push dx
xor ax, ax
xor dx, dx
mov ah, 02h
mov Dl, 46
int 21h
pop Dx
pop Ax
mov Ax, Dx
@optif:
cmp Ax, 10
Jb @optthen
jmp @optendif
@optthen:
push Ax
mov Ax, 0
call putdec
pop Ax
jmp @optendif
@optendif:
call putdec
ret
@outputdollars ENDp
@InputForDay Proc Near C
Mov Cx, 7
Lea Di, onday
Call Putstrng
mov Ax, DAY
call putdec
Mov Cx, 26
Lea Di, lemonadecost
Call Putstrng
invoke @outputdollars, PricePerglass
ret
@InputForDay endp
;#######Asset Statement############
@AssetStatement Proc Near C
invoke @clearscreen, 25
mov cx,31
lea di,dailystatement
call putstrng
call newline
mov cx,8
lea di,date
call putstrng
mov ax,day
call putdec
call newline
ret
@AssetStatement ENDp
main Proc Far
MOV AX,SEG DATA
MOV DS,AX
MOV ES,AX
invoke @clearscreen, 20
Mov Cx, 25
Lea Di, intro
Call Putstrng
Call Newline
invoke @Centstodollars, CASH
call Putdec
call newline
mov ax,dx
call putdec
call newline
invoke @RANDOMNUMBER, RAND_k, RAND_seed, 50
call Putdec
call newline
invoke @RANDOMNUMBER, RAND_k, RAND_seed, 70
call Putdec
call newline
invoke @InputForDay
Mov Ah, 4Ch
Int 21h
main Endp
Code Ends
SSeg Segment STACK
DB 254 dup(?)
SSeg Ends
End main