@program prog_code,prog_name ;********************* Start of Fargo program ******************** ; Guess.asm by Bryan Rittmeyer | ; Hey, its supposed to suck, its my first ASM program for the 68k| ;***************************************************************** prog_code: move.w #01,-(a7) ; Move 1 to the stack jsr romlib[set_font] ; Set the font lea 2(a7),a7 ; Add two to stack pointer bra title_scr ; Display title screen prog_codie: clr.l d0 ; Clear just to be safe move.w #10,d0 ; Set maximum to 9 jsr flib[random] ; Generate random number move.b d0,rand ; Move d0 to rand move.l d0,keepit ; Move d0 to keepit move.b #00,count ; Set counter to zero guess_again: jsr flib[clr_scr] ; Clear Screen cmp.b #3,count ; Compare 3 with count beq game_over ; Out of guesses move.w #4,-(a7) ; Push the color, black on white pea Str1(PC) ; Pushes address of Str move.w #1,-(a7) ; Y Coordinate move.w #1,-(a7) ; X Corrdinate jsr romlib[puttext] ; Put string on screen lea 10(a7),a7 ; Change stack to ignore puttext stuff jsr flib[idle_loop] ; Wait for user to press number cmp.w #264,d0 ; Check to see if esc key beq shutdown ; If esc key, exit move.b d0,gues ; Copy guess to "gues" sub.b #48,gues ; Get rid of ASCII offset cmp.b #0,gues ; Compare gues with 0 blt bad_num ; Below 0 in value, bad... cmp.b #9,gues ; Compare gues and 9 bgt bad_num ; Above 9 in value, bad... move.b rand,d0 ; Copy rand to d0 move.b gues,d1 ; Copy gues to d1 cmp.b d0,d1 ; Compare them beq correct_guess ; Correct Guess, branch... blt too_low ; Too low bgt too_high ; Too high bra guess_again ; This instruction will never be run :-) too_low: move.w #4,-(a7) ; Push the color, black on white pea Str4(PC) ; Pushes address of Str move.w #20,-(a7) ; Y Coordinate move.w #1,-(a7) ; X Corrdinate jsr romlib[puttext] ; Put string on screen lea 10(a7),a7 ; Change stack to ignore puttext shit add.b #1,count ; Add 1 to guess counter jsr flib[idle_loop] ; Wait for user to press a key bra guess_again ; Go back to top of loop too_high: move.w #4,-(a7) ; Push the color, black on white pea Str3(PC) ; Pushes address of Str move.w #20,-(a7) ; Y Coordinate move.w #1,-(a7) ; X Corrdinate jsr romlib[puttext] ; Put string on screen lea 10(a7),a7 ; Change stack to ignore puttext shit add.b #1,count ; Add 1 to guess counter jsr flib[idle_loop] ; Wait for user to press a key bra guess_again ; Go back to top of loop correct_guess: move.w #4,-(a7) ; Push the color, black on white pea Str5(PC) ; Pushes address of Str move.w #50,-(a7) ; Y Coordinate move.w #50,-(a7) ; X Corrdinate jsr romlib[puttext] ; Put string on screen lea 10(a7),a7 ; Change stack to ignore puttext shit jsr flib[idle_loop] ; Wait for user to press a key rts ; Return bad_num: move.w #4,-(a7) ; Push the color, black on white pea Str2(PC) ; Pushes address of Str move.w #20,-(a7) ; Y Coordinate move.w #1,-(a7) ; X Corrdinate jsr romlib[puttext] ; Put string on screen lea 10(a7),a7 ; Change stack to ignore puttext shit jsr flib[idle_loop] ; Wait for user to press a key bra guess_again ; Go back to top of loop game_over: move.w #4,-(a7) ; Push the color, black on white pea Str6(PC) ; Pushes address of Str move.w #30,-(a7) ; Y Coordinate move.w #50,-(a7) ; X Corrdinate jsr romlib[puttext] ; Put string on screen lea 10(a7),a7 ; Change stack to ignore putext stuff move.l keepit(PC),-(a7) ; Push VALUE pea format(PC) ; Push format to stack pea buffer(PC) ; Push buffer addr jsr romlib[sprintf] ; Convert lea 12(a7),a7 ; Change stack move.w #4,-(a7) ; Push the color, black on white pea Str10(PC) ; Pushes address of Str move.w #60,-(a7) ; Y Coordinate move.w #10,-(a7) ; X Corrdinate jsr romlib[puttext] ; Put string on screen lea 10(a7),a7 ; Change stack to ignore puttext stuff move.w #4,-(a7) ; Push the color, black on white pea buffer(PC) ; Pushes address of Str move.w #60,-(a7) ; Y Coordinate move.w #100,-(a7) ; X Corrdinate jsr romlib[puttext] ; Put string on screen lea 10(a7),a7 ; Change stack to ignore puttext stuff jsr flib[idle_loop] ; Pause rts ; Return title_scr: jsr flib[clr_scr] ; Clear Screen move.w #4,-(a7) ; Push the color, black on white pea Str7(PC) ; Pushes address of Str move.w #1,-(a7) ; Y Coordinate move.w #35,-(a7) ; X Corrdinate jsr romlib[puttext] ; Put string on screen lea 10(a7),a7 ; Change stack to ignore puttext stuff move.w #4,-(a7) ; Push the color, black on white pea Str8(PC) ; Pushes address of Str move.w #75,-(a7) ; Y Coordinate move.w #35,-(a7) ; X Corrdinate jsr romlib[puttext] ; Put string on screen lea 10(a7),a7 ; Change stack to ignore puttext stuff move.w #4,-(a7) ; Push the color, black on white pea Str9(PC) ; Pushes address of Str move.w #90,-(a7) ; Y Coordinate move.w #80,-(a7) ; X Corrdinate jsr romlib[puttext] ; Put string on screen lea 10(a7),a7 ; Change stack to ignore puttext stuff jsr flib[idle_loop] ; Wait for user to press a key bra prog_codie ; Go back up to top of program shutdown: rts ; Exit ; Text strings to use in game Str1 dc.b "Enter a Number between 0 and 9:",0 Str2 dc.b "Not a valid number, try again.",0 Str3 dc.b "Too High",0 Str4 dc.b "Too low",0 Str5 dc.b "Correct! You win!",0 Str6 dc.b "Sorry. You lose.",0 Str7 dc.b "Guess 0.6 by Bryan Rittmeyer",0 Str8 dc.b "Thanks to eNdocomp, _Chewy_",0 ; Cool people Str9 dc.b "and Tybster!",0 Str10 dc.b "The number was",0 format dc.b "%ld",0 buffer dc.b " ",0 rand dc.b 0 keepit dc.l 0 count dc.b 0 gues dc.b 0 prog_name: dc.b "Guess 0.6",0 reloc_open add_library flib add_library romlib reloc_close end ; *************************************************************************