; oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo ; O __ __ o O MY O ; o / \____/ \ O Froggies Version 1.01 o o ; O / () () \ o El tres en raya O FIRST O ; o | | O Will Stokes o o ; O \ \____/ / o wstokes@vertex.ucls.uchicago.edu O ZSHELL O ; o \ / O http://www.uic.edu/~hhstokes/ o o ; O \____/ o O GAME O ; o O o o ; OoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoO ; ; Real simple game...it's Tick-Tack-Toe but even better!!!! ; (El tres en raya) ; I got the idea of this on Sept. 4th 1996 when my exchange ; student from Spain came and gave me a version of this game ; made from little green and tan colored frogs and a tile with ; a picture of the entrance to the Universidad in Salamanaca I ; had seen earlier durring spring vacation!!!!!! ; ; It works just like regular Tick-Tack-Toe but more fun. ; When you reach a stalemate or Cat-Scratch, the game continues. ; Say Green just finnished playing his/her last piece and no more ; pieces are available for green or tan then tan can move one of ; his/her pieces and then green etc. etc. etc. until somebody wins. ; Weird trap can be set up and really can be a lot more fun, trust ; me. ; ; Anyway, to finnish this text stuff, thanks to Julio for giving ; me the idea, all the people out there who helped me learn how to ; program in assembly for the Z80 chip (sorry I didn't name all of ; you) and for my friends at school who are always badgering me to ; make/get "some new games", so to them, here is my first zshell ; game. ; ; Will Stokes ; 3-D Diamond Productions ; wstokes@vertex.ucls.uchicago.edu ; http://www.uic.edu/~hhstokes/ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Froggies;;;Froggies;;;Froggies;;;Froggies;;;Froggies;;;Froggies;Froggies;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #include "TI-85.H" ; some setup stuff ; .org 0 ; some setup stuff ; .db "Froggies Version 1.01 W.S.", 0 ; name that appears in zshell menu ; sf = TEXT_MEM ; # of square frogs left tf = TEXT_MEM+1 x = TEXT_MEM+2 ; horizontal placement y = TEXT_MEM+5 ; vertical placement s1 = TEXT_MEM+8 ; \ s2 = TEXT_MEM+9 ; | 7 8 9 s3 = TEXT_MEM+10 ; | 4 5 6 s4 = TEXT_MEM+11 ; | 1 2 3 s5 = TEXT_MEM+12 ; | s6 = TEXT_MEM+13 ; |__Tells values of nine s7 = TEXT_MEM+14 ; | places on board s8 = TEXT_MEM+15 ; | s9 = TEXT_MEM+16 ; / tn = TEXT_MEM+17 ; whose turn is it (sq. or tri.) tn2 = TEXT_MEM+18 ; variable that determines next turn tw = TEXT_MEM+19 tx = TEXT_MEM+20 ; final point when making a line ty = TEXT_MEM+21 tz = TEXT_MEM+22 dir = TEXT_MEM+23 ; w1 = TEXT_MEM+24 sf2 = TEXT_MEM+25 sf3 = TEXT_MEM+26 dir3 = TEXT_MEM+27 s10 = TEXT_MEM+28 ; _________________ ; ; / \ ; ; | Setup Variables | ; Put in initial values of variables ; \_________________/ ; ; ; ; ld a, 0 ; free value for spaces ld (s1), a ; free #1 space ld (s2), a ; free #2 space ld (s3), a ; free #3 space ld (s4), a ; free #4 space ld (s5), a ; free #5 space ld (s6), a ; free #6 space ld (s7), a ; free #7 space ld (s8), a ; free #8 space ld (s9), a ; free #9 space ld a, 1 ; 1=sqr. turn 2= tri. turn ld (tn), a ; start with sqr. ld (sf2), a ld a, 6 ; # of frogs ld (sf), a ; three square frogs ld a, 9 ; ld (sf3), a ld (dir3), a ; ld a, 4 ; set your TI-85 into out (5), a ; Graphics Mode ROM_CALL(CLEARLCD) ; screen cleared set 3, (IY+05) ; set white on black mode for startup ; ; __________________ ; ; / \ ; Prints Intro Text Screen in ; | Print Intro Text | ; White on black BIG text ; \__________________/ ; ; ; ; ld hl, $0001 ; load coordinates of text ld de, Title1 ; load first string CALL_(Text) ; print it ld hl, $0002 ; load new coordinates ld de, Title2 ; load next string CALL_(Text) ; print it ld hl, $0003 ; load new coordinates ld de, Title3 ; load new string CALL_(Text) ; print it ld hl, $0004 ; load new coordinates ld de, Title4 ; load string CALL_(Text) ; print it ld hl, $0005 ; load coordinates ld de, Title5 ; load new string CALL_(Text) ; print it ld hl, $0006 ; load new coordinates ld de, Title6 ; load string CALL_(Text) ; print it ; ___________________________________ ; ; / \ ; Pauses a little while ; | Do a semi-pause so they can see it | ; so they can see it Duh! ; \___________________________________/ ; ; ld c, 9 ; using c as wait variable, wait 9 CALL_(SemiPause) ; do the pause using subrotine ; _________________ ; / \ ; ; | T G ! | ; ; | H A ! | ; And now the game... yeah!!!!! ; | E M ! | ; ; | E ! | ; ; | ! | ; ; \_________________/ ; ; ROM_CALL(CLEARLCD) ; clear the screen res 3, (IY+05) ; set calc. back to black on white ld a, 1 ;1 equals turn point on ld (ty), a ;set variable so pixels will turn on ld a, 27 ; Y = ld c, a ; 27 ld a, 29 ; X = ld b, a ; 29 ld a, 90 ; endpoint ld (tx), a ; endpoint=(tx) CALL_(line) ;\ ld a, 43 ; \ ld c, a ; \ ld a, 29 ; | ld b, a ; | CALL_(line) ; | ld a, 12 ; | ld c, a ; | ld a, 49 ; |__ Draw four lines for ld b, a ; | Tick-Tack-Toe board. ld a, 58 ; | ld (tx), a ; | CALL_(line2) ; | ld a, 12 ; | ld c, a ; | ld a, 70 ; / ld b, a ; / CALL_(line2) ;/ ; / \ ; | Real heart of program is here where commands are processed | ; \ / CALL_(command) ; get keystrokes ret ; return to zshell line: CALL_(SetPixel) ; draw point ld a, (tx) ; compare location cp b ; to end point location jr z, ln2 ; if done go to ln2 ld a, b inc a ; otherwise increase x-variables ld b, a ; and go to top jr line ; ln2: ret line2: CALL_(SetPixel) ; draw point ld a, (tx) ; compare location cp c ; to end point location jr z, ln3 ; if done go to ln3 ld a, c inc a ; otherwise increase y-variables ld c, a ; and go to top jr line2 ; ln3: ret makex: ; \ ld a, (x) ; | ld b, a ; | ld a, 4 ; | Pretty simple, this add a, b ; | section makes an "X" ld (x), a ; | ld a, (y) ; | ld b, a ; | ld a, 2 ; | add a, b ; | ld (y), a ;;| ld a, (x) ;; ld b, a ;; ld a, (y) ;; ld c, a ;; CALL_(SetPixel) ;; inc b ;; CALL_(SetPixel) ;; inc b ;; inc c ;; CALL_(SetPixel) ;; inc b ;; inc c ; CALL_(SetPixel) ; inc b ; inc c ; CALL_(SetPixel) ; inc b ; inc c ; CALL_(SetPixel) ; inc b ; CALL_(SetPixel) ; inc c ; CALL_(SetPixel) ; dec b ; CALL_(SetPixel) ; dec b ;; inc c ; CALL_(SetPixel) ; dec b ; inc c ; CALL_(SetPixel) ; dec b ; inc c ; CALL_(SetPixel) ; dec b ; inc c ; CALL_(SetPixel) ; dec b ; CALL_(SetPixel) ; ld a, 7 ; add a, b ; ld b, a ; dec c ; dec c ; dec c ; CALL_(SetPixel) ; inc b ; inc c ; CALL_(SetPixel) ; inc b ; inc c ; CALL_(SetPixel) ; inc b ; inc c ; CALL_(SetPixel) ; inc b ; CALL_(SetPixel) ; dec c ; dec c ; dec c ; dec c ; dec c ; dec c ; dec c ; dec c ; dec c ; CALL_(SetPixel) ; dec b ; CALL_(SetPixel) ; dec b ; inc c ; CALL_(SetPixel) ; dec b ; inc c ; CALL_(SetPixel) ; dec b ; inc c ; CALL_(SetPixel) ; ret ; makey: ; ld a, (x) ; This section ld b, a ; makes a "O" ld a, 8 ; add a, b ; ld b, a ; ld a, (y) ; ld c, a inc c inc c inc c CALL_(SetPixel) inc b CALL_(SetPixel) inc b CALL_(SetPixel) inc b CALL_(SetPixel) inc b CALL_(SetPixel) inc b inc c CALL_(SetPixel) inc b inc c CALL_(SetPixel) inc b inc c CALL_(SetPixel) inc c CALL_(SetPixel) inc c CALL_(SetPixel) dec b inc c CALL_(SetPixel) dec b inc c CALL_(SetPixel) dec b inc c CALL_(SetPixel) dec b CALL_(SetPixel) dec b CALL_(SetPixel) dec b CALL_(SetPixel) dec b CALL_(SetPixel) dec b dec c CALL_(SetPixel) dec b dec c CALL_(SetPixel) dec b dec c CALL_(SetPixel) dec c CALL_(SetPixel) dec c CALL_(SetPixel) inc b dec c CALL_(SetPixel) inc b dec c CALL_(SetPixel) ret command: CALL_(getter) ; comprehend last command CALL_(winner) ; is there a winner? ld a, (dir) ; save command cp $37 ; exit? ret z ; yes, return to (eventually) zshell jr command ; look for another command getter: ld a, 1 ld (tn2), a ld a, 0 ld (tz), a call GET_KEY ld (dir), a cp 34 CALL_Z(k1) cp 26 CALL_Z(k2) cp 18 CALL_Z(k3) cp 35 CALL_Z(k4) cp 27 CALL_Z(k5) cp 19 CALL_Z(k6) cp 36 CALL_Z(k7) cp 28 CALL_Z(k8) cp 20 CALL_Z(k9) ret fix: ld a, 1 ret checker: ld (tw), a ld a, 0 ld (tz), a ld a, (tw) cp 0 CALL_Z(check2) ld a, (tw) cp 1 CALL_Z(check3) ld a, (tw) cp 2 CALL_Z(check3) ret check2: ld a, (dir) ld b, a ld a, (dir3) cp b CALL_Z(bop) ld a, 1 ld (ty), a ld a, (sf) cp 0 CALL_Z(check5) ld a, (sf3) cp 3 CALL_Z(bop) ret check5: ld a, (sf2) cp 1 CALL_Z(bop) ld a, 1 ld (sf2) ,a ret check3: ld a, (dir) ld (dir3), a cp 27 CALL_Z(bop) ld a, 0 ld (sf2), a ld (ty), a ld (tn2), a ld a, (tw) ld b, a ld a, (tn) cp b CALL_NZ(bop) ld a, (sf) cp 1 CALL_Z(bop) cp 2 CALL_Z(bop) cp 3 CALL_Z(bop) cp 4 CALL_Z(bop) cp 5 CALL_Z(bop) cp 6 CALL_Z(bop) ld a, (sf) inc a ld (sf) ,a ld a, (tz) cp 1 CALL_Z(bop2) ld a, (sf3) cp 4 CALL_Z(bop) ret bop: ld a, 1 ld (tz), a ret bop2: ld a, (sf) dec a ld (sf), a ret k1: ld a, (s1) CALL_(checker) ld a, 29 ld (x), a ld a, 12 ld (y), a jr kk1 k2: ld a, (s2) CALL_(checker) ld a, 50 ld (x), a ld a, 12 ld (y), a jr kk1 k3: ld a, (s3) CALL_(checker) ld a, 71 ld (x), a ld a, 12 ld (y), a jr kk1 kk1: jr k10 k4: ld a, (s4) CALL_(checker) ld a, 29 ld (x), a ld a, 28 ld (y), a jr k10 k5: ld a, (s5) CALL_(checker) ld a, 50 ld (x), a ld a, 28 ld (y), a jr k10 k6: ld a, (s6) CALL_(checker) ld a, 71 ld (x), a ld a, 28 ld (y), a jr k10 k7: ld a, (s7) CALL_(checker) ld a, 29 ld (x), a ld a, 44 ld (y), a jr k10 k8: ld a, (s8) CALL_(checker) ld a, 50 ld (x), a ld a, 44 ld (y), a jr k10 k9: ld a, (s9) CALL_(checker) ld a, 71 ld (x), a ld a, 44 ld (y), a k10: ld a, (tz) cp 1 ret z ld a, (tn) cp 1 CALL_Z(makex) cp 2 CALL_Z(makey) CALL_(update) ld a, (dir) ret update: ld a, (tn) ld (w1), a ld a, (ty) cp 0 CALL_Z(zero) ld a, (ty) cp 1 CALL_Z(z2) CALL_(update2) ld a, (tn2) ld b, a ld a, (tn) add a, b ld (tn), a cp 3 CALL_Z(fix) ld (tn), a ret z2: ld a, (sf3) dec a ld (sf3), a ld a, 9 ld (dir3), a ret uu: inc a ret dd: dec a ret update2: ld a, (sf) cp 1 CALL_Z(dd) cp 2 CALL_Z(dd) cp 3 CALL_Z(dd) cp 4 CALL_Z(dd) cp 5 CALL_Z(dd) cp 6 CALL_Z(dd) ld (sf), a ld a, (dir) cp 34 CALL_Z(l1) cp 26 CALL_Z(l2) cp 18 CALL_Z(l3) cp 35 CALL_Z(l4) cp 27 CALL_Z(l5) cp 19 CALL_Z(l6) cp 36 CALL_Z(l7) cp 28 CALL_Z(l8) cp 20 CALL_Z(l9) ret fix2: ld a, (sf) inc a ld (sf), a ret l1: ld a, (w1) ld (s1), a ld a, (dir) ret l2: ld a, (w1) ld (s2), a ld a, (dir) ret l3: ld a, (w1) ld (s3), a ld a, (dir) ret l4: ld a, (w1) ld (s4), a ld a, (dir) ret l5: ld a, (w1) ld (s5), a ld a, (dir) ret l6: ld a, (w1) ld (s6), a ld a, (dir) ret l7: ld a, (w1) ld (s7), a ld a, (dir) ret l8: ld a, (w1) ld (s8), a ld a, (dir) ret l9: ld a, (w1) ld (s9), a ld a, (dir) ret zero: ld a, (sf3) inc a ld (sf3) ,a ld a, 0 ld (w1), a ret ; ####################################### winner: ; ####### Is there a winner????? ######## ; ####################################### ld a, (s1) ld (s10), a ld b, a ld a, (s4) cp b jr nz, n1 ld a, (s7) cp b jr z, win3 n1: ld a, (s2) ld (s10), a ld b, a ld a, (s5) cp b jr nz, n2 ld a, (s8) cp b jr z, win3 n2: ld a, (s3) ld (s10), a ld b, a ld a, (s6) cp b jr nz, n3 ld a, (s9) cp b jr z, win3 win3: jr win n3: ld a, (s7) ld (s10), a ld b, a ld a, (s8) cp b jr nz, n4 ld a, (s9) cp b jr z, win n4: ld a, (s4) ld (s10), a ld b, a ld a, (s5) cp b jr nz, n5 ld a, (s6) cp b jr z, win n5: ld a, (s1) ld (s10), a ld b, a ld a, (s2) cp b jr nz, n6 ld a, (s3) cp b jr z, win n6: ld a, (s1) ld (s10), a ld b, a ld a, (s5) cp b jr nz, n7 ld a, (s9) cp b jr z, win n7: ld a, (s3) ld (s10), a ld b, a ld a, (s5) cp b jr nz, n8 ld a, (s7) cp b jr z, win n8: ret win: ld hl, $0204 ; load coordinates of text ld a, (s10) cp 0 ret z cp 1 CALL_Z(x4) ld a, (s10) cp 2 CALL_Z(y4) CALL_(Text) ; print it ld hl, $0205 ld de, www CALL_(Text) ld c, 20 ; using c as wait variable, wait 20 CALL_(SemiPause) ; do the pause using subrotine ld a, $37 ld (dir), a ret x4: ld de, xwin ret y4: ld de, ywin ret SetPixel: ld a, (ty) cp 1 jr z, Pon jr Poff Pon: ROM_CALL(FIND_PIXEL) ld de,VIDEO_MEM add hl,de or (hl) ld (hl),a ret Poff: ROM_CALL(FIND_PIXEL) ld de,VIDEO_MEM add hl,de xor 255 and (hl) ld (hl),a ret text2: ld ($8333),hl ld hl, (PROGRAM_ADDR) add hl, de ROM_CALL(D_ZM_STR) ret SemiPause: ld a,$FF ld b,$FF SemiPause2: dec a jr nz,SemiPause2 dec b jr nz,SemiPause2 dec c jr nz,SemiPause2 ret Text: ld ($800C),hl ld hl, (PROGRAM_ADDR) add hl, de ROM_CALL(D_ZT_STR) ret jr nz,SemiPause2 ret Title1: .db "Froggies Version 1.01",0 Title2: .db "Will Stokes (c.) 1996",0 Title3: .db " wstokes@vertex. ",0 Title4: .db " ucls.uchicago.edu ",0 Title5: .db " http://www.uic.edu ",0 Title6: .db "/~hhstokes/index.html",0 xwin: .db "X-X-X Wins!!!!!!!",0 ywin: .db "O-O-O Wins!!!!!!!",0 www: .db "El tres en raya!!",0 .end