@program prog_code,prog_name include macros.h ;************** Start of Fargo program ************** prog_code: move.l #0,col move.l #0,row ;lea col1(PC),a2 ;move.w #2,4(a2) ;move.w #1,6(a2) ;move.w #2,8(a2) ;move.w #1,10(a2) ;move.w #2,18(a2) ;move.w #2,20(a2) ;move.w #1,22(a2) mainmenu: jsr flib[clr_scr] setfont #2 WriteStr #64,#20,#1,title setfont #1 WriteStr #0,#35,#1,about WriteStr #55,#60,#1,choice1 WriteStr #55,#70,#1,choice2 WriteStr #55,#80,#1,choice3 clr.l d0 jsr flib[idle_loop] cmp.w #268,d0 beq moveloop cmp.w #269,d0 beq reset bra end reset: clr.l d0 move.l #2,plr move.l #0,row move.l #0,col move.l #42,d0 lea col1(PC),a0 resetloop: cmp.l #0,d0 beq mainmenu move.w #0,(a0) sub.l #1,d0 add.l #2,a0 bra resetloop moveloop: clr.l d0 bsr showscr move.l #3,pcol getkeyloop: setfont #1 WriteStr #114,#42,#1,curplrstr cmp.l #1,plr beq inpisy WriteStr #210,#42,#1,x bra donexyinp inpisy: WriteStr #210,#42,#1,y donexyinp: setfont #2 WriteStr #110,#12,#1,title move.l pcol,d0 mulu #8,d0 add.l #35,d0 WriteStr d0,#72,#1,uparrow clr.l d0 jsr flib[idle_loop] cmp.l #337,d0 beq left cmp.l #340,d0 beq right cmp.l #13,d0 beq doneselect cmp.l #264,d0 beq mainmenu left: cmp.l #0,pcol beq getkeyloop bsr erase sub.l #1,pcol bra getkeyloop right: cmp.l #6,pcol beq getkeyloop bsr erase add.l #1,pcol bra getkeyloop doneselect: move.l pcol(PC),d0 mulu #6,d0 lea col1(PC),a2 mulu #2,d0 add.w d0,a2 move.l #5,row cmp.w #0,(a2) bne getkeyloop next: cmp.l #0,row beq put move.l a2,a3 add.l #2,a3 ;get next row cmp.w #1,(a3) beq put cmp.w #2,(a3) beq put move.l a3,a2 sub.l #1,row bra next put: cmp.l #1,plr beq toy move.l #1,plr bra dplr toy: move.l #2,plr dplr: move.l plr,d0 move.w d0,(a2) ;bsr repstate bsr showscr bra getkeyloop showscr: jsr flib[clr_scr] setfont #1 WriteStr #12,#93,#1,keys1 WriteStr #42,#103,#1,keys2 setfont #2 lea col1(PC),a2 clr.l d2 move.l #0,row move.l #0,col startofloop: lea col1(PC),a2 move.l col,d2 ;Where to get it from mulu #6,d2 add.l row,d2 mulu #2,d2 add.l d2,a2 move.l row(PC),d0 ;place to print it mulu #10,d0 move.l col(PC),d1 mulu #8,d1 add.l #12,d0 add.l #35,d1 cmp.w #1,(a2) beq isx cmp.w #2,(a2) beq isy bra noval isx: WriteStr d1,d0,#1,x bra noval isy: WriteStr d1,d0,#1,y noval: cmp.l #5,row beq otherloop add.l #1,row bra startofloop otherloop: move.l #0,row add.l #1,col cmp.l #7,col beq end bra startofloop end: ;jsr flib[idle_loop] rts repstate: move.l d0,d5 move.l d1,d6 move.l d2,d7 move.l a0,a4 move.l a1,a5 move.l a2,a6 move.l #7,d4 setfont #1 WriteStr #152,#8,#1,sd0 move.l d5,d0 move.l #1,d1 move.l #22,d2 jsr hexlib[put_hex] WriteStr #152,#16,#2,sd1 move.l d6,d0 move.l #22,d2 move.l #2,d1 jsr hexlib[put_hex] WriteStr #152,#24,#2,sd2 move.l d7,d0 move.l #22,d2 move.l #3,d1 jsr hexlib[put_hex] WriteStr #152,#40,#2,sa0 move.l a4,d0 move.l #22,d2 move.l #5,d1 jsr hexlib[put_hex] WriteStr #152,#48,#2,sa1 move.l a5,d0 move.l #22,d2 move.l #6,d1 jsr hexlib[put_hex] WriteStr #152,#56,#2,sa2 move.l a6,d0 move.l #22,d2 move.l #7,d1 jsr hexlib[put_hex] WriteStr #152,#72,#2,srow move.l row(pc),d0 move.l #22,d2 move.l #9,d1 jsr hexlib[put_hex] WriteStr #152,#80,#2,scol move.l col(pc),d0 move.l #22,d2 move.l #10,d1 jsr hexlib[put_hex] setfont #2 jsr flib[idle_loop] move.l d5,d0 move.l d6,d1 move.l d7,d2 move.l a4,a0 move.l a5,a1 move.l a6,a2 rts erase: move.w #82,-(a7) move.l pcol,d0 mulu #8,d0 add.l #35,d0 add.l #10,d0 move.w d0,-(a7) move.w #72,-(a7) sub.l #10,d0 move.w d0,-(a7) jsr flib[erase_rect] add.l #8,a7 rts ;**************************************************** prog_name: dc.b "Connect 4 by DSPlaisted",0 x: dc.b "X",0 y: dc.b "O",0 row: dc.l 0 ;current row col: dc.l 0 ;current column plr: dc.l 2 ;current player pcol: dc.l 3 col1: ds.w 42 sd0: dc.b "d0:",0 sd1: dc.b "d1:",0 sd2: dc.b "d2:",0 sa0: dc.b "a0:",0 sa1: dc.b "a1:",0 sa2: dc.b "a2:",0 srow: dc.b "row:",0 scol: dc.b "col:",0 title: dc.b "FConnect4 v1.1",0 choice1: dc.b "F1: Play FConnect4",0 choice2: dc.b "F2: Clear playing field",0 choice3: dc.b "F3: Exit",0 keys1: dc.b 17,", ",18,", Enter: Put a piece in a column",0 keys2: dc.b "Esc: Exit to the main menu",0 about: dc.b "By Daniel Plaisted (dsplaisted@juno.com)",0 uparrow: dc.b 27,0 ;if that doesn't work, try 23 space: dc.b " ",0 curplrstr: dc.b "Current Player:",0 ;************** End of Fargo program **************** reloc_open add_library flib add_library romlib add_library hexlib reloc_close end