Короче немного переделал вывод. Разбил на блок инициализации и блок отрисовки.
Добавил опрос джопстика и теперь рожу можно погонять по экрану.
sprites.mfk:
Код:
const byte pmgmem=$80 //pmgmem*256 == place for sprites
void sprInit() {
poke($D407,pmgmem)//PMGBASE place in memory
poke ($022F,%111110)//SDMCTL
poke ($D01D,3)//GRACTL Enable PM display
poke ($026F,1)//GPRIOR priority
poke ($D008,0)//SIZEP0 size of player 0: ;0 = normal, 1 = double, 3 = quadruple
}
void sprShow(pointer _sprData, byte _sprSize, byte _sprColor, byte x, byte y) {
pointer pmg0
ubyte i
poke ($02C0,_sprColor)//$CF - PCOLR0 color of player 0
//poke ($02C0,$CA)//PCOLR0 color of player 0
poke ($D000,x)// $30 HPOSP0 horisontal place player 0
// copy sprite data to defined place
pmg0=word((pmgmem*256)+1024+y)
for i,0,to,_sprSize-1 {
pmg0[i]=_sprData[i]
}
}
test.mfk:
Код:
import stdio
import sprites
array hello_world = "Hello ATARI!"
array(byte) sprite0 = [
%00000000,
%00111100,
%01000010,
%10000001,
%10100101,
%10000001,
%10000001,
%10000001,
%10100101,
%10011001,
%10000001,
%01000010,
%00111100,
%00000000
]
noinline asm void wait(byte register(a) f) {
clc
adc os_RTCLOK.b2
.rt_check:
cmp os_RTCLOK.b2
bne .rt_check
rts
}
void main() {
byte pX
byte pY
byte joy
putstr(hello_world, hello_world.length)
new_line()
putstrz("Hello world again"z)
new_line()
sprInit()
// byte i
// for i,48,to,200 {
// wait(1)
// sprCreate(sprite0, sprite0.length, $CF, i, 30)
// }
pX = 60
pY = 30
putstrz("PosX: "z)
putword(pX)
putstrz(" PosY: "z)
putword(pY)
sprShow(sprite0, sprite0.length, %11000000, pX, pY)
while (true) {
wait(1)
joy = peek(632)
if (joy == 11 || joy == 10 || joy == 9) {
pX -= 1
} else if (joy == 7 || joy == 6 || joy == 5) {
pX += 1
}
if (joy == 14 || joy == 10 || joy == 6) {
pY -= 1
} else if (joy == 13 || joy == 9 || joy == 5) {
pY += 1
}
if (joy != 15) {
sprShow(sprite0, sprite0.length, %11000000, pX, pY)
}
}
}