Added hello world VCS sample.

Fixed charset indices.
This commit is contained in:
g012 2017-10-05 11:48:56 +02:00
parent ae256b8e2c
commit cdf1add9f3
4 changed files with 100 additions and 6 deletions

View File

@ -8,8 +8,11 @@ compiler:
script:
- cmake . -DCMAKE_BUILD_TYPE=Release
- make
- ./l65 samples/vcs0.l65
- ./l65 samples/vcs1.l65
- cd samples
- ../l65 vcs0.l65
- ../l65 vcs1.l65
- ../l65 vcs_hello.l65
- cd ..
deploy:
provider: releases
api_key:

View File

@ -628,8 +628,8 @@ M.charset = function(s, f)
if st == 'table' then M.cs = s return s end
if not f then f = function(v) return v end
elseif type(f) == 'number' then f = function(v) return v + f end end
local t={}
for c in s:gmatch'.' do t[c]=f(#t) end
local t,i={},0
for c in s:gmatch'.' do t[c]=f(i) i=i+1 end
M.cs=t
return t
end

91
samples/vcs_hello.l65 Normal file
View File

@ -0,0 +1,91 @@
require'vcs'
mappers['2K']()
local tmp = 0x80
section{ "font", align=256 } dc.b
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,-- <SPC>
0x18,0x3c,0x66,0x7e,0x66,0x66,0x66,0x00,-- A
0x7c,0x66,0x66,0x7c,0x66,0x66,0x7c,0x00,-- B
0x3c,0x66,0x60,0x60,0x60,0x66,0x3c,0x00,-- C
0x78,0x6c,0x66,0x66,0x66,0x6c,0x78,0x00,-- D
0x7e,0x60,0x60,0x78,0x60,0x60,0x7e,0x00,-- E
0x7e,0x60,0x60,0x78,0x60,0x60,0x60,0x00,-- F
0x3c,0x66,0x60,0x6e,0x66,0x66,0x3c,0x00,-- G
0x66,0x66,0x66,0x7e,0x66,0x66,0x66,0x00,-- H
0x3c,0x18,0x18,0x18,0x18,0x18,0x3c,0x00,-- I
0x1e,0x0c,0x0c,0x0c,0x0c,0x6c,0x38,0x00,-- J
0x66,0x6c,0x78,0x70,0x78,0x6c,0x66,0x00,-- K
0x60,0x60,0x60,0x60,0x60,0x60,0x7e,0x00,-- L
0x63,0x77,0x7f,0x6b,0x63,0x63,0x63,0x00,-- M
0x66,0x76,0x7e,0x7e,0x6e,0x66,0x66,0x00,-- N
0x3c,0x66,0x66,0x66,0x66,0x66,0x3c,0x00,-- O
0x7c,0x66,0x66,0x7c,0x60,0x60,0x60,0x00,-- P
0x3c,0x66,0x66,0x66,0x66,0x3c,0x0e,0x00,-- Q
0x7c,0x66,0x66,0x7c,0x78,0x6c,0x66,0x00,-- R
0x3c,0x66,0x60,0x3c,0x06,0x66,0x3c,0x00,-- S
0x7e,0x18,0x18,0x18,0x18,0x18,0x18,0x00,-- T
0x66,0x66,0x66,0x66,0x66,0x66,0x3c,0x00,-- U
0x66,0x66,0x66,0x66,0x66,0x3c,0x18,0x00,-- V
0x63,0x63,0x63,0x6b,0x7f,0x77,0x63,0x00,-- W
0x66,0x66,0x3c,0x18,0x3c,0x66,0x66,0x00,-- X
0x66,0x66,0x66,0x3c,0x18,0x18,0x18,0x00,-- Y
0x7e,0x06,0x0c,0x18,0x30,0x60,0x7e,0x00 -- Z
charset(" abcdefghijklmnopqrstuvwxyz", \x(x*8))
@@text_hello dc.b "hello world"
local print_txt = tmp+1 -- text pointer, can cross
local print_line_count=tmp -- number of lines to print
local print_ptr = tmp+3 -- array of pointers to the characters
-- a = line count
@@print12
sta print_line_count
lda#6 sta NUSIZ0 sta NUSIZ1
-- set MSB of font character addresses
lda#font>>8 ldx#23 @_loadfont sta print_ptr,x dex dex bpl _loadfont
-- position sprites
samepage
sta WSYNC
ldx#6 @_delay dex bne _delay
sta RESP0 nop sta RESP1 lda#0x70 sta HMP0 lda#0x60 sta HMP1 sta WSYNC sta HMOVE
end
@_loop
-- load text line
ldx#0 ldy#0 @_loadline lda (print_txt),y sta print_ptr,x inx inx iny cpy#12 bne _loadline
lda#0x80 sta HMP0 sta HMP1
ldy#0 samepage @_printline
sta WSYNC sta HMOVE
-- first scanline
lda (print_ptr+2),y sta GRP0 lda (print_ptr+6),y sta GRP1
lda (print_ptr+22),y tax sleep(6)
lda (print_ptr+10),y sta GRP0 lda (print_ptr+14),y sta GRP1 lda (print_ptr+18),y sta GRP0 stx GRP1
sta HMCLR sleep(8) sta HMOVE
-- second scanline
lda (print_ptr),y sta GRP0 lda (print_ptr+4),y sta GRP1
lda (print_ptr+20),y tax lda#0x80 sta HMP0 sta HMP1 nop
lda (print_ptr+8),y sta GRP0 lda (print_ptr+12),y sta GRP1 lda (print_ptr+16),y sta GRP0 stx GRP1
iny cpy#8 bne _printline
end
dec print_line_count beq _end
lda print_txt clc adc#12 sta print_txt lda print_txt+1 adc#0 sta print_txt+1
jmp _loop
@_end
lda#0 sta GRP0 sta GRP1
rts
local kernel = function()
ldx#40 @_blank sta WSYNC dex bne _blank
setptr(text_hello,print_txt) lda#1 jsr print12
end
@@main
init()
lda#0xaa sta COLUP0 sta COLUP1
@_frame
overscan() vblank() screen(kernel) jmp _frame
;
writebin(filename..'.bin')
writesym(filename..'.sym')
print(stats)

View File

@ -182,8 +182,8 @@ screen_begin = function() lda#TV.TIM_KERNEL sta T1024T end
screen_end = wait
screen = function(f) screen_begin() if f then f() end screen_end() end
setptr = function(f) lda#op_resolve(f)&0xff sta mappers.tmp lda#op_resolve(f)>>8 sta mappers.tmp+1 end
xcall = function(f) setptr(f) jsr jmpfar end
setptr = function(f, add) if not add then add=tmp end lda#op_resolve(f)&0xff sta add lda#op_resolve(f)>>8 sta add+1 end
xcall = function(f) setptr(f, mappers.tmp) jsr jmpfar end
rtximp = function() jmp rtsfar end
-- for mappers that swap banks in place