lorom ;org $90E0E6 ; JSL $809DE7 ;Call timer code. If SEC at return, white screen of death ;Run 9DFB,X (X is 2*0943, the timer type) ;Things I'll need: ;Store any given time to timer, start timer (Go to count down) ;Count timer down (stop at 0) ;Count timer up (stop at 59'59"99) ;JSL $809F6C - Display timer (run when 0943 is not 0) ;Will handle movement of timer (use high byte of 0943 for instruction index, and low of 0948 and 094A for variables) ;Instruction options: ;Display normal ;Display glitched (room dependant) ;Move ;7E:0943 Timer type (00 = No timer, 01 = Count down, 02 = Count up) ;7E:0944 Timer movement (00 = Do nothing, 01 = Center timer, 02 = Delaying motion, 03 = Move to topright) ;7E:0945 Timer, centiseconds (in decimal) ;7E:0946 Timer, seconds (in decimal) ;7E:0947 Timer, minutes (in decimal) ;7E:0948 Timer Y position (pixels) ;7E:0949 Timer X position (pixels) ;7E:094A Timer Display (0 = normal, 1 = scroll with screen, 2 = glitched graphics) ;7E:094B Timer Motion Delay ;I don't see a need for a 'Turn off timer' routine. So. org $809E09 print pc STZ $0943 NOP print pc org $809E1C print pc STZ $0943 NOP print pc org $82804A print pc STZ $0943 NOP print pc org $82836F print pc JSL TimerMotion print pc org $828390 print pc JSL TimerMotion print pc org $82E267 print pc JSL TimerMotion print pc org $82E297 print pc JSL TimerMotion print pc org $90E10F print pc JSL TimerMotion print pc org $90E114 print pc JSL TimerMotion print pc org $90E1C3 print pc JSL TimerMotion print pc org $90E1F2 print pc JSL TimerMotion print pc org $809DFB ;Stop *before* 80:9FD4 print pc TimerModifications: DW NoTimer, CountDown, CountUp ;Fill with as many as needed NoTimer: CLC RTS GetModifier: LDA $05B6 STA $4204 SEP #$38 LDA #$03 STA $4206 NOP NOP CLC RTS CountDown: JSR GetModifier LDA #$99 LDX $4216 BEQ + DEC + ADC $0945 STA $0945 BCS + LDA $0946 SBC #$00 STA $0946 BCS + LDA $0947 SBC #$00 STA $0947 BCC ++ LDA #$59 STA $0946 BRA + ++ STZ $0945 STZ $0946 STZ $0947 + REP #$39 LDA $0945 ORA $0946 BNE + SEC + RTS CountUp: JSR GetModifier LDA #$01 LDX $4216 BEQ + INC + ADC $0945 STA $0945 BCC ++ LDA $0946 ADC #$00 CMP #$60 BNE + LDA $0947 ADC #$00 BCS ++ STA $0947 TDC + STA $0946 ++ REP #$39 RTS TimerMotion: PHB PHK PLB LDA $0944 AND #$00FF BEQ ++ DEC ASL TAX JSR (TimerMotions,X) ++ LDA $094A AND #$00FF ASL TAX JMP (TimerDisplays,X) TimerDisplays: DW NormalDisplay, GlitchedDisplay, ScrollingDisplay NormalDisplay: LDY #$A060 TDC JSR NDisplay1 LDA $0947 LDX #$FFE4 JSR NDisplay2 LDA $0946 LDX #$FFFC JSR NDisplay2 LDA $0945 LDX #$0014 JSR NDisplay2 PLB RTL NDisplay2: PHX PHA AND #$00F0 LSR A LSR A LSR A TAX LDY $9FD4, X LDA $03, S JSR NDisplay1 PLA AND #$000F ASL A TAX LDY $9FD4, X PLA ADC #$0008 NDisplay1: STA $14 LDA $0949 AND #$00FF CLC ADC $14 STA $14 LDA $0948 AND #$00FF STA $12 LDA #$0A00 STA $16 JSL $81879F ; $879F IN ROM RTS GlitchedDisplay: LDY.w #GT TDC JSR NDisplay1 LDA $0947 LDX #$FFE4 JSR GDisplay2 LDA $0946 LDX #$FFFC JSR GDisplay2 LDA $0945 LDX #$0014 JSR GDisplay2 PLB RTL GDisplay2: PHX PHA AND #$00F0 LSR A LSR A LSR A TAX LDY.w GNumbers, X LDA $03, S JSR NDisplay1 PLA AND #$000F ASL A TAX LDY.w GNumbers, X PLA ADC #$0008 JMP NDisplay1 GNumbers: DW G0, G1, G2, G3, G4, G5, G6, G7, G8, G9 G0: DB $02,$00, $FC,$01,$00,$BA,$3B DB $FC,$01,$F8,$B0,$3B G1: DB $02,$00, $FC,$01,$00,$BB,$3B DB $FC,$01,$F8,$B1,$3B G2: DB $02,$00, $FC,$01,$00,$BC,$3B DB $FC,$01,$F8,$B2,$3B G3: DB $02,$00, $FC,$01,$00,$BD,$3B DB $FC,$01,$F8,$B3,$3B G4: DB $02,$00, $FC,$01,$00,$BE,$3B DB $FC,$01,$F8,$B4,$3B G5: DB $02,$00, $FC,$01,$00,$BF,$3B DB $FC,$01,$F8,$B5,$3B G6: DB $02,$00, $FC,$01,$00,$C0,$3B DB $FC,$01,$F8,$B6,$3B GT: DB $05,$00, $F0,$01,$F0,$C8,$3B DB $E8,$01,$F0,$C7,$3B DB $E0,$01,$F0,$C6,$3B DB $08,$00,$F8,$C5,$3B DB $F0,$01,$F8,$C4,$3B print pc ;Before 80:9FD4? org $80D80A print pc G7: DB $02,$00, $FC,$01,$00,$C1,$3B DB $FC,$01,$F8,$B7,$3B G8: DB $02,$00, $FC,$01,$00,$C2,$3B DB $FC,$01,$F8,$B8,$3B G9: DB $02,$00, $FC,$01,$00,$C3,$3B DB $FC,$01,$F8,$B9,$3B ScrollingDisplay: LDY #$A060 TDC JSR SDisplay1 LDA $0947 LDX #$FFE4 JSR SDisplay2 LDA $0946 LDX #$FFFC JSR SDisplay2 LDA $0945 LDX #$0014 JSR SDisplay2 PLB RTL SDisplay2: PHX PHA AND #$00F0 LSR A LSR A LSR A TAX LDY $9FD4, X LDA $03, S JSR SDisplay1 PLA AND #$000F ASL A TAX LDY $9FD4, X PLA ADC #$0008 SDisplay1: STA $14 LDA $0949 SEC SBC $0911 AND #$00FF CLC ADC $14 STA $14 LDA $0948 SEC SBC $0915 AND #$00FF STA $12 LDA #$0A00 STA $16 JSL $81879F ; $879F IN ROM RTS TimerMotions: DW CenterTimer,Delay,MoveUpRight CenterTimer: LDA #$8080 STA $0948 INC $0944 LDA #$4000 STA $094A RTS Delay: LDA $094B AND #$00FF BEQ + DEC $094B RTS + INC $0944 RTS MoveUpRight: LDA $0948 SEP #$20 CMP #$30 BEQ + DEC $0948 + XBA INC STA $0949 CMP #$DC BNE + STZ $0944 + REP #$20 RTS print pc ;Switch to later in bank when this area is full. DO NOT OVERWRITE TOO MUCH ;Implementation notes: A6C126 is where Ridley sets it. org $A6C117 print pc STZ $0FB2 ;Not sure if this is even necessary LDA #$AA50 STA $0FA8 LDA #$0101 STA $0943 ;Set timer (Centered, decreasing) STA $0946 ;Set time (1 minute 1 second) LDA #$0002 STA $093F DEC JSL $8081A6 RTS print pc