ROBOT.BRAINS

Looking through old 6502 code archives

Been looking through old 6502 code archives, and ran across this snippet of code from my game Fort Apocalypse. I’ve always gotten a thrill when watching Terminator because when we see the robot's code from his point of view, it's a 6502, and it looks sort of like this.


ROBOT.BRAINS

     LDA R.STATUS

     CMP #OFF

     BEQ .1

     CMP #CRASH

     BEQ .2

     LDA FRAME

     AND ROBOT.SPD

     BEQ R.START

     RTS

*

     LDA TIM7.VAL

     BEQ .0

.1   DEC TIM7.VAL

     BNE .2

.0   LDA #$88

     STA PCOLR2

     STA PCOLR3

     LDA #8

     STA ROBOT.ANGLE

     LDA RANDOM

     AND #7

     LDX LEVEL

     DEX         X=1?

     BNE .3

     CLC

     ADC #8

.3   TAX

     LDA ROB.X,X

     STA R.X

     LDA ROB.Y,X

     STA R.Y

     LDA R.X

     SEC

     SBC CHOP.X

     BPL .4

     EOR #-2

.4   CMP #34

     BGE .6

     LDA R.Y

     SEC

     SBC CHOP.Y

     BPL .5

     EOR #-2

.5   CMP #8

     BLT .2

.6   LDA #FLY

     STA R.STATUS

     LDX #0

     STX R.FX

     STX R.FY

     STX TIM7.VAL

     INX         X=1

     STX TIM8.VAL

     JMP POS.ROBOT

.2   RTS

Looking for something specific?

Don’t sweat it, we’ve got you covered.

Main

Team

Legal