//#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 {{bss_init}} ; initialize data segment {{!start}} ; start main routine .segment "VECTORS" Return: .word $6060 VecNMI: VecReset: .word Main::__Reset VecBRK: .word Main::__BRK --- end component Player end component KernelSection lines: 1..255 end component BGColor bgcolor: 0..255 end component PFColor pfcolor: 0..255 end component Playfield pf: 0..0xffffff end component AsymPlayfield pfleft: 0..0xffffff pfright: 0..0xffffff end component VersatilePlayfield data: array of 0..255 baseoffset -1 end system FrameLoop on start do once --- @NextFrame: FRAME_START {{emit preframe}} KERNEL_START {{emit kernel}} KERNEL_END {{emit postframe}} FRAME_END {{emit nextframe}} jmp @NextFrame ; loop to next frame --- end system ResetSwitch on nextframe do once --- lsr SWCHB ; test Game Reset switch bcs @NoStart {{!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] --- asl {{$0}} bcs @SkipMoveRight {{!joyright}} @SkipMoveRight: asl {{$0}} bcs @SkipMoveLeft {{!joyleft}} @SkipMoveLeft: asl {{$0}} bcs @SkipMoveDown {{!joydown}} @SkipMoveDown: asl {{$0}} bcs @SkipMoveUp {{!joyup}} @SkipMoveUp: --- end system SetHorizPos on SetHorizPos do once --- ; SetHorizPos routine ; A = X coordinate ; Y = player number (0 or 1) sta WSYNC ; start a new line sec ; set carry flag nop @DivideLoop: sbc #15 ; subtract 15 bcs @DivideLoop ; branch until negative eor #7 ; calculate fine offset asl asl asl asl sta RESP0,y ; fix coarse position sta HMP0,y ; set fine offset --- end system StaticKernel on preframe do foreach [KernelSection] limit 1 --- {{!kernelsetup}} --- on kernel do foreach [KernelSection] --- sta WSYNC {{!kernelsetup}} {{!kerneldraw}} {{!kerneldone}} --- on kerneldraw do with [KernelSection] --- ldy {{