Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NAME r1,input
- NAME r3,port
- NAME r11,choices
- NAME r13,room
- NAME r14,sp
- NAME r15,ip
- main:
- ;setup
- MOV #sp,0
- MOV #room,game.start
- MOV #port,0
- .loop:
- ;READ ROOM INFO
- MOV #choices,[#room] ;read the number of choices
- ADD #choices,1 ;add 1 since it's easier to work with internally
- ;DISPLAY ROOM
- SEND #port,0x3000 ;CLS
- SEND #port,0x1000 ;LOCATE 0,0
- SEND #port,0x200F ;COLOR white,black
- ADD #room,#choices ;move past option data
- CALL #room ;run code for the current room
- SUB #room,#choices ;go back
- ;INPUT
- SEND #port,0x1160 ;LOCATE 0,11
- SEND #port,0x20E0 ;COLOR black,yellow
- .getinput:
- RECV #input,#port
- JNC .getinput ;repeat until success
- SUB #input,48 ;convert from ascii to number (0-9)
- JBE .getinput ;if "0" or below
- CMP #input,#choices ;compare with # of choices (+1)
- JAE .getinput ;if > choices
- ADD #input,48 ;convert back to ascii (this fails if input was <48 but we don't allow that anyway)
- SEND #port,#input ;display character
- SUB #input,48 ;actually we want a number (saving a register is worth 1 cycle, I think)
- MOV #room,[#room+#input] ;the location of the next room
- JMP .loop
- game:
- .start: ;room label
- dw 3 ;# of choices
- dw .one ;choice 1
- dw .two ;choice 2
- dw .three ;choice 3
- SEND #port,"enter 1, 2, or 3" ;code to run
- RET ;required
- .one:
- dw 1
- dw .start
- SEND #port,"one"
- RET
- .two:
- dw 1
- dw .start
- SEND #port,"two"
- RET
- .three:
- dw 1
- dw .start
- SEND #port,"three"
- RET
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement