ORG $000 * * * MACSBUG EQU $200F6 OUTPUT2 EQU $21BC2 FIXBUF EQU $21F18 MSG EQU $200EE X1 EQU $1000 Y1 EQU $1001 X2 EQU $1002 Y2 EQU $1003 COLOR EQU $1010 NCOLOR EQU $1011 OCOLOR EQU $1012 NUMPT EQU $1014 SCALE EQU $1016 RANADD EQU $1018 ARRAY EQU $1080 TABLECH EQU $1100 CMDTAB EQU $1800 * * SETUP: MOVE.L $578,A0 MOVE.L #CMDTAB,A1 MOVE.L A1,$578 SETUP1: MOVE (A0)+,D0 CMPI #$FFFF,D0 BEQ.S SETUP2 MOVE D0,(A1)+ MOVE.L (A0)+,(A1)+ BRA SETUP1 SETUP2: CMP.L #$22000,A0 BPL.S INIT MOVE.L #$22082,A0 BRA SETUP1 INIT: MOVE D0,(A1) MOVE.L #$220D2,A0 MOVE #$9000,D0 INIT1: MOVE.B D0,$1FFFD MOVE.B (A0)+,D1 NOP MOVE.B D1,$1FFFF ADD #1,D0 CMPI #$0010,D0 BNE INIT1 MOVE.L #$229F6,A1 MOVE.L #TABLECH,A2 MOVE #770,D0 SETUP21: MOVE.B (A1)+,(A2)+ SUB #1,D0 BNE SETUP21 BRA.S RETURN CM: MOVE.L #$10000,A0 MOVE #$2000,D1 CLR.L D0 CLRM: MOVE.L D0,(A0)+ SUB #1,D1 BNE CLRM NOP RETURN: JMP MACSBUG NTABLE: DC.W 'CM' DC.L $22068 DC.W 'SH' DC.L $220E2 DC.W 'BX' DC.L $2218A DC.W 'ED' DC.L $221E8 DC.W 'BA' DC.L $22454 DC.W 'Q1' DC.L $22498 DC.W 'Q2' DC.L $224A4 DC.W 'Q3' DC.L $224B0 DC.W 'Q4' DC.L $224BC DC.W 'Q5' DC.L $224C8 DC.W 'Q9' DC.L $22606 DC.W 'HP' DC.L $226AC DC.W 'Q8' DC.L $22818 DC.W $FFFF ; WNUNNI ; NONTONIO; NONTONION * * * * CRTC: DC.B $27 DC.B $20 DC.B $22 DC.B $A3 DC.B $20 DC.B $06 DC.B $1F DC.B $1F DC.B $10 DC.B 7 DC.L 0 DC.W 0 * * SH: BSR SHQ BRA RETURN SHQ: JSR OUTPUT2 MOVE.L #$3FF21,A1 SH1: BSR INPUT CMP.B #$0D,D0 BEQ.S SH2 CMP.B #$FF,D0 BNE SH1 BRA.S SH3 SH2: BSR INPUT CMPI.B #$0A,D0 BEQ SH2 CMPI.B #0,D0 BEQ SH2 CMPI.B #$FF,D0 BEQ.S SH3 JSR FIXBUF MOVE.L #'ERRO',(A6)+ MOVE.L #'R ;C',(A6)+ MOVE.L #'HECK',(A6)+ MOVE.L #' FIL',(A6)+ MOVE.L #'E ',(A6)+ JMP MSG SH3: MOVE.L #$10000,A0 MOVE.B #$55,D0 BSR OUTPUT SH4: BSR INPUT MOVE.B D0,D1 BSR INPUT ASL #8,D0 MOVE.B D1,D0 MOVE.W D0,(A0)+ CMP.L #$17F80,A0 BNE SH4 RTS INPUT: MOVE.B (A1),D0 ANDI.B #1,D0 BEQ INPUT MOVE.B 2(A1),D0 RTS OUTPUT: MOVE.B (A1),D7 ANDI.B #2,D7 BEQ OUTPUT MOVE.B D0,2(A1) RTS BX: CLR D0 MOVE D0,D1 MOVE D0,D2 BX3: MOVE #$3F,D3 MOVE.L #$10000,A0 BX1: BSR SHOW SUB #2,D3 BPL.S BX2 BRA BX3 BX2: ADD #1,D0 ADD #1,D1 ADD #1,D2 ADD.L #514,A0 BRA BX1 SHOW: MOVE D3,D4 BX11: MOVE D0,(A0)+ SUB #1,D4 BNE BX11 MOVE D0,(A0) MOVE D3,D4 ASL #2,D4 BX22: ADD.L #128,A0 MOVE D1,(A0) SUB #1,D4 BNE BX22 MOVE D3,D4 MOVE D0,(A0) BX33: MOVE D0,-(A0) SUB #1,D4 BNE BX33 MOVE D3,D4 ASL #2,D4 BX44: SUB.L #128,A0 MOVE D2,(A0) SUB #1,D4 BNE BX44 RTS * * * ED: MOVE.B #$80,X1 MOVE.B #$80,Y1 MOVE.B #0,NCOLOR ED1: BSR BLINK BSR CMD BRA ED1 CMD: BSR READK CMPI.B #$20,D1 BPL.S RTS CMPI.B #$B,D1 BEQ.S UPARROW CMPI.B #$A,D1 BEQ.S DWARROW CMPI.B #$C,D1 BEQ.S RTARROW CMPI.B #$8,D1 BEQ.S LTARROW CMPI.B #$1,D1 BEQ.S CMD1 CHARMODE CMPI.B #$3,D1 BEQ.S CMD2 NCOLOR CMPI.B #$4,D1 BEQ.S CMD3 CMPI.B #$0D,D1 BEQ.S CR CMPI.B #$5,D1 BEQ.S CMD4 CMPI.B #$11,D1 BNE.S RTS1 ADD.L #4,A7 BRA.W RETURN UPARROW: SUB.B #1,81 RTS1: CLR D1 RTS: RTS DWARROW: ADD.B #1,81 BRA.S RTS1 RTARROW: ADD.B #1,X1 BRA.S RTS1 LTARROW: SUB.B #1,X1 BRA.S RTS1 CMD1: ADD.L #4,A7 BRA.W CHARED CMD3: ADD.L #4,A7 BRA.W DOT CMD4: ADD.L #4,A7 BRA.W ED1 CR: ADD.B #7,Y1 MOVE.B #0,X1 BRA RTS1 CMD2: BSR READK MOVE.L #NCOLOR,A3 CMPI.B #'R',D1 BEQ.S RED CMPI.B #'G',D1 BEQ.S GREEN CMPI.B #'B',D1 BEQ.S BLUE CMPI.B #'W',D1 BEQ.S WHITE CMPI.B #'Z',D1 BEQ.S BLACK CMPI.B #'Y',D1 BEQ.S YELLOW CMPI.B #'M',D1 BEQ.S MAG CMPI.B #'C',D1 BEQ.S CYAN CMPI.B #'T',D1 BEQ.S DRED CMPI.B #'H',D1 BEQ.S DGR CMPI.B #'N',D1 BEQ.S DBLUE CMPI.B #'E',D1 BEQ.S DWH CMPI.B #'U',D1 BEQ.S DYEL CMPI.B #',',D1 BEQ.S DMAG CMPI.B #'V',D1 BEQ.S DCYAN RTS2: CLR D1 RTS RED: MOVE.B #$9,(A3) BRA RTS2 GREEN: MOVE.B #$A,(A3) BRA RTS2 BLUE: MOVE.B #$C,(A3) BRA RTS2 WHITE: MOVE.B #$F,(A3) BRA RTS2 BLACK: MOVE.B #0,(A3) BRA RTS2 YELLOW: MOVE.B #$B,(A3) BRA RTS2 MAG: MOVE.B #$D,(A3) BRA RTS2 CYAN: MOVE.B #$E,(A3) BRA RTS2 DRED: MOVE.B #1,(A3) BRA RTS2 DGR: MOVE.B #2,(A3) BRA RTS2 DBLUE: MOVE.B #4,(A3) BRA RTS2 DWH: MOVE.B #7,(A3) BRA RTS2 DYEL: MOVE.B #3,(A3) BRA RTS2 DMAG: MOVE.B #5,(A3) BRA RTS2 DCYAN: MOVE.B #6,(A3) BRA RTS2 BLINK: MOVE.B X1,D1 MOVE.B Y1,D2 BSR GETADD NOT D3 BL2: CMPI.B #$F,D3 BEQ.S BL1 LSR #4,D3 LSR #4,D1 BRA.S BL2 BL1: MOVE.B D1,OCOLOR BL3: MOVE.B #$F,D0 MOVE.B X1,D1 MOVE.B Y1,D2 BSR DSP BSR DLY CLR.B D0 BSR DSP BSR DLY MOVE.B OCOLOR,D0 BSR DSP BSR DLY MOVE.B $3FF01,D0 ANDI.B #1,D0 BEQ BL3 RTS * CHARED: MOVE X1,82 BSR BLINK BSR CMD TST.B D1 BEQ CHARED BSR CHAR BRA CHARED CHAR: SUB.B #$20,D1 ASL #3,D1 MOVE.L #TABLECH,A3 AND.L #$3FF,D1 ADD.L D1,A3 MOVE #4,D6 CHARED1: CLR D5 CHARED2: BTST D5,(A3) BNE.S SET CHARED3: ADD.B #1,X2 ADD #1,D5 CMPI #16,D5 BNE.S CHARED4 ADD.B #1,42 MOVE.B X1,X2 ADD.L $2,A3 SUB #1,D6 BNE CHARED1 ADD.B #8,X1 RTS CHARED4: CMPI #8,D5 BNE CHARED2 ADD.B #1,Y2 MOVE.B X1,X2 BRA CHARED2 SET: MOVE.B NCOLOR,D0 MOVE.B X2,D1 MOVE.B Y2,D2 BSR DSP BRA CHARED3 * DOT: MOVE.B NCOLOR,D0 MOVE.B X1,D1 MOVE.B Y1,D2 BSR DSP BSR BLINK BSR CMD BRA DOT * READK: MOVE.B $3FF01,D1 ANDI.B #1,D1 BEQ READK MOVE.B $3FF03,D1 RTS DLY: MOVE #$00FF,D6 DLY1: SUB #1,D6 BNE DLY1 RTS * * * BA: MOVE.L #$10000,A0 MOVE.L #$3FF23,A1 MOVE.L #$3FF21,A2 L1: MOVE.B (A2),D1 ANDI.B #$2,D1 BEQ L1 MOVE.B #$65,D0 MOVE.B D0,(A1) LOOP: MOVE.B (A2),D1 ANDI.B #$2,D1 BEQ LOOP MOVE (A0)+,D0 MOVE.B D0,(A1) LSR #8,D0 L2: MOVE.B (A2),D1 ANDI.B #$2,D1 BEQ L2 MOVE.B D0,(A1) CMP.L #$18000,A0 BNE LOOP BRA RETURN * * * Q1: MOVE.L #$225AC,A6 MOVE $10,D7 BRA.S RUN Q2: MOVE.L #$225BE,A6 MOVE #$10,D7 BRA.S RUN Q3: MOVE.L #$225D0,A6 MOVE #$10,D7 BRA.S RUN Q4: MOVE.L #$225E2,A6 MOVE #$10,D7 BRA.S RUN Q5: MOVE.L #$225F4,A6 MOVE #$10,D7 RUN: BSR RUN1 BRA RETURN * * * RUN1: MOVE #128,D6 BSR RAND RUN2: JSR (A6) MOVEM.L D1/D2,-(A7) AND #$7F,D1 AND #$7F,D2 BSR DSPLY NEG.B D1 BSR DSPLY NEG.B D2 BSR DSPLY NEG.B D1 BSR DSPLY MOVEM.L (A7)+,D1/D2 SUB #1,D6 BNE RUN2 SUB #1,D7 BNE RUN1 RTS RAND: BSR RAND1 MOVE D0,D1 BSR RAND1 MOVE D0,D2 RAND2: BSR RAND1 ANDI.B #$F,D0 BEQ RAND2 CMPI.B #$08,D0 BEQ RAND2 RTS RAND1: MOVE.B RANADD+1,D0 ASL.B #2,D0 ADD.B RANADD,D0 ASL #8,D0 MOVE.B RANADD+1,D0 ASL #2,D0 ADD RANADD,D0 ADD #$3619,D0 MOVE D0,RANADD LSR #8,D0 RTS * * * *DSPLY (C,X,Y) * D0=COLOR * D1=X 8-BITS * D2=Y 8-BITS * DSP: MOVEM.L D0-D3/A0,-(A7) BRA.S DSP1 * DSPLY: MOVEM.L D0-D3/A0,-(A7) ADD.B #128,D1 ADD.B #128,D2 DSP1: AND #$F,D0 BSR GETADD AND D3,D1 OR D1,D0 MOVE D0,(A0) MOVEM.L (A7)+,D0-D3/A0 RTS GETADD: AND #$FF,D1 MOVE #$FFF0,D3 ASL #8,D2 ADD D2,D1 AND.L $FFFF,D1 MOVE D1,D2 LSR #2,D1 ASL #1,D1 MOVE.L #$10800,A0 ADD.L D1,A0 AND #3,D2 BEQ.S DSPLY1 DSPLY2: ASL #4,D0 ROL #4,D3 SUB #1,D2 BNE DSPLY2 DSPLY1 MOVE (A0),D1 RTS * * EQU1: MOVE D1,D3 MOVE D2,D4 EXT D3 EXT D4 LSR #3,D3 LSR #3,D4 SUB.B D3,D2 SUB.B D4,D1 RTS * EQU2: MOVE D2,D3 EXT D3 LSR #3,D3 SUB.B D3,D1 MOVE D1,D4 EXT D4 LSR #3,D4 ADD.B D4,D2 RTS * * EQU3: MOVE D2,D3 EXT D3 LSR #1,D3 ADD.B D3,D1 MOVE D1,D4 EXT D4 LSR #1,D4 SUB.B D4,D2 RTS * EQU4: MOVE D2,D3 EXT D3 LSR #3,D3 SUB.B D3,D1 MOVE D1,D4 EXT D4 LSR #3,D4 SUB.B D4,D2 RTS * EQU5: MOVE D2,D3 EXT D3 LSR #1,D3 SUB.B D3,D1 MOVE D1,D4 EXT D4 LSR #2,D4 ADD.B D4,D2 RTS Q9: MOVE.L #$225AC,A6 Q91: MOVE #2,D5 Q92: BSR CMQ MOVE #$20,D7 BSR RUN1 BSR DLYQ MOVEM.L D5/A6,-(A7) BSR HP1 MOVEM.L (A7)+,D5/A6 BSR DLYQ SUB #1,D5 BNE Q92 BSR LOGO ADD.L #$12,A6 CMP.L #$22696,A6 BEQ Q8 BRA Q91 DLYQ: MOVE.L #$00DAFFFF,D4 DLYQ1: SUB.L #1,D4 BNE DLYQ1 RTS CMQ: CLR.L D0 MOVE #$2000,D1 MOVE.L #$10000,A0 CMQ1: MOVE.L D0,(A0)+ SUB #1,D1 BNE CMQ1 RTS LOGO: MOVEM.L D0-D7/A3-A6,-(A7) JSR FIXBUF MOVE.L #'SH S',(A6)+ MOVE.L #'LIDE',(A6)+ MOVE.B #' ',(A6) BSR SHQ BSR DLYQ JSR FIXBUF MOVE.L #'SH M',(A6)+ MOVE.L #'ASK ',(A6)+ BSR SHQ MOVEM.L (A7)+,D0-D7/A0-A6 MOVE.L #$9010FFFF,D4 BRA DLYQ1 * HP: BSR HP1 BRA RETURN HP1: MOVE.L #ARRAY,A3 BSR CMQ CLR D1 CLR D2 MOVE #$FF,D3 MOVE D3,D4 BSR RAND1 ANDI.B #7,D0 ADD.B #5,D0 ASL #1,D0 MOVE.B D0,NUMPT BSR RAND1 ANDI.B #$1F,D0 OR.B #$5,D0 MOVE.B D0,SCALE CLR D5 H6: BSR RAND1 AND #$FF,D0 MOVE.B D0,0(A3,D5) CMP D0,D1 BPL.S H1 MOVE.B D0,D1 H1: CMP D0,D3 BMI.S H2 MOVE.B D0,D3 H2: BSR RAND1 AND #$FF,D0 MOVE.B D0,1(A3,D5) CMP D0,D2 BPL.S H3 MOVE.B D0,D2 H3: CMP D0,D4 BMI.S H4 MOVE.B D0,D4 H4: CMP.B NUMPT,D5 BEQ.S H5 ADD.B #2,D5 BRA H6 H5: EQU * H8: SUB.B D3,D1 SUB.B D4,D2 CLR D5 H61: SUB.B D3,0(A3,d5) SUB.B D4,1(A3,D5) CMP.B NUMPT,D5 BEQ.S H9 ADD.B #2,D5 BRA H61 H9: CLR D3 MOVE.L #$FF00,D0 AND #$FF,D1 DIVU D1,D0 CLR D5 H12: MOVE.B 0(A3,D5),D3 MULU D0,D3 LSR #8,D3 MOVE.B D3,0(A3,D5) CMP.B NUMPT,D5 BEQ.S H11 ADD.B #2,D5 BRA H12 H11: MOVE.L #$FF00,D0 AND #$FF,D2 DIVU D2,D0 CLR D5 H14: MOVE.B 1(A3,D5),D3 MULU D0,D3 LSR #8,D3 MOVE.B D3,1(A3,D5) CMP.B NUMPT,D5 BEQ.S H13 ADD.B #2,D5 BRA H14 H13: MOVE (A3),X1 H131: MOVE #$10,D7 H132: ADD.B #2,NUMPT MOVE.B NUMPT,D5 MOVE (A3),(A3,D5) H15: MOVE #4,D6 BSR RAND1 AND #$F,D0 BEQ H15 CMPI.B #$8,D0 BEQ.S H15 CMPI.B #$F,D0 BEQ H15 HP6: CLR D5 H17: MOVE.B (A3,D5),D1 MOVE.B 1(A3,D5),D2 HP17: BSR LINE CMP.B NUMPT,D5 BEQ.S H16 MOVE.B 2(A3,D5),D1 MOVE.B 0(A3,D5),D2 AND #$FF,D1 AND #$FF,D2 SUB D2,D1 MOVE.B SCALE,D3 AND #$FF,D3 MULS D3,D1 LSR #8,D1 ADD.B D1,(A3,D5) MOVE.B 3(A3,D5),D1 AND #$FF,D1 MOVE.B 1(A3,D5),D2 AND #$FF,D2 SUB D2,D1 MOVE.B SCALE,D3 AND #$FF,D3 MULS D3,D1 LSR #8,D1 ADD.B D1,1(A3,D5) ADD #2,D5 BRA H17 H16: SUB #1,D6 BNE HP6 SUB #1,D7 BNE H15 RTS Q8: BSR HP1 MOVE.L #$AFFFF,D4 BSR DLYQ1 BRA Q8 * * * DXDY: MOVE.B 2(A1),D1 SUB.B (A1),D1 BCS.S XNEG MOVE.B D1,4(A1) CLR.B 6(A1) RTS XNEG: MOVE.B #1,6(A1) NEG.B D1 MOVE.B D1,4(A1) RTS * * LINE EQU * DRAW: MOVEM.L D0-D7/A0-A6,-(A7) MOVE.L #X1,A1 MOVE.B D1,2(A1) MOVE.B D2,3(A1) MOVE.B (A1),D1 MOVE.B 1(A1),D2 BSR DSP DRAW1: BSR DXDY ADD.L #1,A1 BSR DXDY SUB.L #1,A1 MOVE.B (A1),D1 MOVE.B 1(A1),D2 TST.B 4(A1) BEQ.S DXZ TST.B 5(A1) BEQ DYZ MOVE.B 4(A1),D3 CMP.B 5(A1),D3 BNE FULMOV TST.B 6(A1) BNE.S SXN TST.B 7(A1) BNE.S SYN XPYPI: BSR DSP ADD.B #1,D1 ADD.B #1,D2 CMP.B 2(A1),D1 BNE XPYPI BRA.S XYDONE SXNSYN: BSR DSP SUB.B #1,D1 SUB.B #1,D2 CMP.B 2(A1),D1 BNE SXNSYN BRA.S XYDONE SXN: TST.B 7(A1) BNE.S SXNSYN SNP: BSR DSP SUB.B #1,D1 ADD.B #1,D2 CMP.B 2(A1),D1 BNE SNP BRA.S XYDONE SYN: BSR DSP ADD.B #1,D1 SUB.B #1,D2 CMP.B 2(A1),D1 BNE SYN BRA.S XYDONE DXZ: TST.B 5(A1) BEQ.S XYDONE TST.B 7(A1) BNE.S DXZYN DXZ1: BSR DSP ADD.B #1,D2 CMP.B 3(A1),D2 BNE DXZ1 BRA.S XYDONE DXZYN: BSR DSP SUB.B #1,D2 CMP.B 3(A1),D2 BNE DXZYN BRA.S XYDONE DYZ: TST.B 6(A1) BNE.S DYZN DYZ1: BSR DSP ADD.B #1,D1 CMP.B 2(A1),D1 BNE DYZ1 BRA.S XYDONE DYZN: BSR DSP SUB.B #1,D1 CMP.B 2(A1),D1 BNE DYZN XYDONE: MOVE 2(A1),(A1) MOVE.B (A1),D1 MOVE.B 1(A1),D2 BSR DSP MOVEM.L (A7)+,D0-D7/A0-A6 RTS FULMOV: MOVE (A1),8(A1) MOVE.B 4(A1),D3 SUB.B 5(A1),D3 BHI.S FUL1 MOVE #$1,10(A1) BRA.S FUL4 FUL1: MOVE #$100,10(A1) BRA.S FUL4 FUL2: MOVE.B 8(A1),D3 SUB.B (A1),D3 BCC.S FUL21 NEG.B D3 FUL21: AND #$FF,D3 MOVE.B 5(A1),D4 AND #$FF,D4 MULU D4,D3 MOVE.B 9(A1),D4 SUB.B 1(A1),D4 BCC.S FUL22 NEG.B D4 FUL22: MOVE.B 4(A1),D5 AND #$FF,D4 AND #$FF,D5 MULU D5,D4 TST.B 10(A1) BNE.S FULY CMP.L D3,D4 BEQ.S GREAT BHI.S GREAT FUL4: MOVE 10(A1),14(A1) BRA.S SAME FULY: CMP.L D3,D4 BEQ.S GREAT BHI.S FUL4 GREAT: MOVE #$0101,14(A1) SAME: MOVE.B 8(A1),D2 MOVE.B 9(A1),D2 TST.B 7(A1) BNE.S NEGY ADD.B 15(A1),D2 BRA.S S2 NEGY: SUB.B 15(A1),D2 S2: MOVE.B D2,9(A1) TST.B 6(A1) BNE.S NEGX ADD.B 14(A1),D1 BRA.S S3 NEGX: SUB.B 14(A1),D1 S3: MOVE.B D1,8(A1) FUL3: BSR DSP CMP.B 2(A1),D1 BEQ.S DRAW2 CMP.B 3(A1),D2 BEQ.S DRAW2 BRA FUL2 DRAW2: MOVE 8(A1),(A1) BRA DRAW1 SIMHALT ; halt simulator * Put variables and constants here END SETUP ; last line of source