; Guess it very beta 3. A port of a casio game. ;) ; By Arnaud Cornet [NoHaR] on irc... ; Everybody knows this game but it's a cool prog to learn from... ; It stands more like a real game now the number to guess is ; a random number. Thanks to Boom2Envy on irc for this... ; Also inputint subroutine has improved. ; `~*ñº|ºñ*~ -=Ø=- 68K's great! -=Ø=- ~*ñº|ºñ*~` @program prog_code,prog_name include macros.h prog_code: clr.l d0 jsr flib[clr_scr] SetFont #2 WriteStr #70,#10,#1,intro1 WriteStr #30,#30,#1,intro2 SetFont #1 WriteStr #75,#50,#1,mode1 WriteStr #75,#60,#1,mode2 WriteStr #75,#70,#1,mode3 WriteStr #1,#100,#4,copy WriteStr #1,#110,#4,copy2 jsr flib[idle_loop] jsr flib[clr_scr] move.l d0,-(a7) SetFont #2 DrawBox #50,#30,#180,#80 move.l (a7)+,d0 cmp.l #268,d0 beq m1 cmp.l #269,d0 beq m2 cmp.l #270,d0 beq m3 cmp.l 264,d0 beq quit rts m1: move.l #9999,(max) move.l #4,(ndig) WriteStr #90,#50,#1,beau1 jmp okm m2: move.l #99999,(max) move.l #5,(ndig) WriteStr #90,#50,#1,beau3 jmp okm m3: move.l #999999,(max) move.l #6,(ndig) WriteStr #90,#50,#1,beau2 jmp okm okm: move.l (max),d0 jsr flib[random] move.l d0,(sol) clr.l d0 go: DrawBox #50,#30,#180,#80 SetFont #2 WriteStr #1,#10,#4,essai move.l #0,(ess) bsr inputint cmp.l #264,d0 beq quit ;***************** did you guess? ****************** move.l (sol),d5 cmp.l (ess),d5 bne non SetFont #1 WriteStr #80,#70,#1,gagne jsr flib[idle_loop] jmp quit non: SetFont #1 cmp.l (ess),d5 bge grand WriteStr #60,#70,#1,tpgr jsr flib[idle_loop] jsr flib[clr_scr] jmp go grand: WriteStr #60,#70,#1,tptit jsr flib[idle_loop] jsr flib[clr_scr] jmp go quit: rts ;****** I finaly found how to prompt for an int!! **** inputint: move.l #1,d2 move.l #0,(ess) getnextkey: jsr flib[idle_loop] ; waits a keypress cmp.l #48,d0 ; bge l1 ; Those lines check if the key pressed rts ; is a number... l1: ; cmp.l #57,d0 ; else (Esc or enter stops subroutine) ble l2 ; rts ; l2: sub.l #48,d0 ;If the pressed key is "0", then d0 is 48 move.l d0,d1 ;If the pressed key is "1", then d0 is 49 and so on jmp infin ;so, d0 - 48 answers the number of the pressed key(0 to 9) rts infin: clr.l d3 move.l (ess),d3 ; Say you just typed "1" d3 is 1. mulu #10,d3 ; now you press "1" then: d3 is 1 x 10 = 10, move.l d3,(ess) ; d3 goes in ess var, add.l d1,(ess) ; and d1 + ess goes in ess thus: 10+1 =11 . ; Finaly if you type 1 and 1 then ess=11 ;) jsr flib[clr_scr] SetFont #2 WriteStr #1,#10,#4,essai movem d0-d7/a0-a6,-(a7) clr.l d0 clr.l d1 move.l (ess),d0 move.l (ndig),d1 lea strbuf(pc),a0 bsr ConvStr ; puts integer d0 of d1 digits, in strbuf as a string DrawBox #50,#30,#180,#80 WriteStr #90,#50,#1,strbuf movem (a7)+,d0-d7/a0-a6 jmp getnextkey ; Back to top: another key rts ConvStr: ;thanks to J. Mardel for this routine! adda.l d1,a0 clr.b (a0) subq.b #1,d1 RepConv: divu #10,d0 move.l d0,d2 lsr.l #8,d2 lsr.l #8,d2 add.b #48,d2 move.b d2,-(a0) and.l #$FFFF,d0 dbra d1,RepConv rts max dc.l 0 ndig dc.l 0 ess dc.l 0 sol dc.l 0 strbuf dc.l 0,0 mode1 dc.b "F1 : easy",0 mode2 dc.b "F2 : normal",0 mode3 dc.b "F3 : hard",0 intro1 dc.b "Guess it !!",0 intro2 dc.b "A cool game for fargo !",0 copy dc.b "By Arnaud Cornet: arnaud_c@worldnet.fr",0 copy2 dc.b "My nick is [NoHaR] on irc...",0 essai dc.b "Let's try:",0 gagne dc.b " Ya won !!!!",0 tptit dc.b "Too low, try again",0 tpgr dc.b "Too high, try again",0 beau1 dc.b "0000",0 beau2 dc.b "00000",0 beau3 dc.b "000000",0 prog_name: dc.b "Guess it 0.3 by A.Cornet",0 reloc_open add_library flib add_library romlib add_library hexlib reloc_close end