2017-09-22 10:29:48 +00:00
|
|
|
require'vcs'
|
2017-09-21 20:55:09 +00:00
|
|
|
|
|
|
|
TIM_OVERSCAN = 50 -- TIM64T, 3200 cycles = ~ 42 scanlines
|
|
|
|
TIM_VBLANK = 61 -- TIM64T, 3904 cycles = ~ 51 scanlines
|
|
|
|
TIM_KERNEL = 17 -- T1024T, 17408 cycles = ~229 scanlines
|
|
|
|
|
|
|
|
location(0xf000, 0xffff)
|
|
|
|
|
2017-09-22 10:29:48 +00:00
|
|
|
section{'vectors', org=0xfffc} dc.w start,start
|
|
|
|
|
2017-09-21 20:55:09 +00:00
|
|
|
local kernel = function()
|
2017-10-01 22:40:38 +00:00
|
|
|
-- add a dummy instruction to collect cycle count and binary size
|
|
|
|
local kernel_cycles,kernel_size
|
|
|
|
table.insert(section_current.instructions, { bin=function() kernel_cycles=cycles kernel_size=size end })
|
|
|
|
|
|
|
|
samepage
|
|
|
|
ldx#0xd0 @_loop sta WSYNC stx COLUBK dex bne _loop
|
|
|
|
end
|
|
|
|
|
|
|
|
-- and get the delta (cycles are counted without taking any branch)
|
|
|
|
table.insert(section_current.instructions, { bin=function() print('kernel cycles: ', cycles-kernel_cycles, 'kernel size: ', size-kernel_size) end })
|
2017-09-21 20:55:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local wait = function() local l=label() lda INTIM bne l end
|
|
|
|
|
|
|
|
@@start
|
|
|
|
-- clear zeropage
|
|
|
|
cld ldx#0 txa @_clear dex tsx pha bne _clear
|
|
|
|
@main
|
|
|
|
-- overscan
|
|
|
|
sta WSYNC lda#2 sta VBLANK lda#TIM_OVERSCAN sta TIM64T wait()
|
|
|
|
-- vblank
|
|
|
|
lda#0b1110 @_vsync sta WSYNC sta VSYNC lsr bne _vsync
|
|
|
|
lda#2 sta VBLANK lda#TIM_VBLANK sta TIM64T wait() sta WSYNC sta VBLANK
|
|
|
|
-- kernel
|
|
|
|
lda#TIM_KERNEL sta T1024T kernel() wait()
|
|
|
|
jmp main
|
2017-09-30 12:53:27 +00:00
|
|
|
;
|
2017-09-21 20:55:09 +00:00
|
|
|
writebin(filename..'.bin')
|
|
|
|
writesym(filename..'.sym')
|
|
|
|
print(stats)
|