//#resource "vcs-ca65.h" system Init on main_init do once --- .include "vcs-ca65.h" .macpack longbranch .define PAL 0 __NMI: __Reset: __BRK: CLEAN_START {{!start}} ; start main routine .segment "VECTORS" ZeroByte: .byte $00 Return: .byte $60 VecNMI: VecReset: .word __Reset VecBRK: .word __BRK .code --- end component Player end component KernelSection lines: 1..255 default 1 end component BGColor bgcolor: 0..255 end component FGColor fgcolor: 0..255 end component PFColor pfcolor: 0..255 end component Playfield pf: 0..0xffffff end component AsymPlayfield pfleft: 0..0xffffff pfright: 0..0xffffff end system FrameLoop on start do once --- {{emit preframeloop}} @NextFrame: FRAME_END {{emit prevsync}} FRAME_START {{emit preframe}} {{emit prekernel}} KERNEL_START {{emit kernel}} KERNEL_END {{emit postkernel}} {{emit postframe}} jmp @NextFrame ; loop to next frame --- on postframe do once --- lsr SWCHB ; test Game Reset switch bcs @NoStart {{emit resetswitch}} @NoStart: --- end system ResetConsole on resetswitch do once --- jmp Main::__Reset ; jump to Reset handler --- end system JoyButton on postframe do foreach [Player] --- lda {{index INPT4}} ;read button input bmi @NotPressed {{emit joybutton}} @NotPressed: --- end system Joystick locals 1 on postframe do once --- ; 2 control inputs share a single byte, 4 bits each lda SWCHA sta {{$0}} --- on postframe do foreach [Player] limit 2 --- asl {{$0}} .ifdef EVENT__joyright bcs @SkipMoveRight {{!joyright}} @SkipMoveRight: .endif asl {{$0}} .ifdef EVENT__joyleft bcs @SkipMoveLeft {{!joyleft}} @SkipMoveLeft: .endif asl {{$0}} .ifdef EVENT__joydown bcs @SkipMoveDown {{!joydown}} @SkipMoveDown: .endif asl {{$0}} .ifdef EVENT__joyup bcs @SkipMoveUp {{!joyup}} @SkipMoveUp: .endif --- end system SetHorizPos on SetHorizPos do critical fit 22 once --- ; SetHorizPos routine ; A = X coordinate ; Y = player number (0 or 1) sec ; set carry flag sta WSYNC ; start a new line : sbc #15 ; subtract 15 bcs :- ; branch until negative eor #7 ; calculate fine offset asl asl asl asl sta HMP0,y ; set fine offset sta RESP0,y ; fix coarse position sta WSYNC ; won't overrun if X < 150 --- end system StandardKernel on wsync do once --- sta WSYNC --- on preframe do foreach [KernelSection] limit 1 --- {{!wsync}} {{!kernelsetup}} --- on kernel do foreach [KernelSection] --- {{!wsync}} {{!kernelsetup}} {{!kerneldraw}} {{!kerneldone}} --- on kerneldraw do with [KernelSection] --- ldy {{