diff --git a/c/rpg.cdt b/c/rpg.cdt index d31613f..b0b7633 100644 Binary files a/c/rpg.cdt and b/c/rpg.cdt differ diff --git a/c/rpg.dsk b/c/rpg.dsk index ac6ee85..607fb1e 100644 Binary files a/c/rpg.dsk and b/c/rpg.dsk differ diff --git a/c/rpg.sna b/c/rpg.sna index 85ea73c..c18ceee 100644 Binary files a/c/rpg.sna and b/c/rpg.sna differ diff --git a/c/src/main.c b/c/src/main.c index 7609988..3137e2f 100644 --- a/c/src/main.c +++ b/c/src/main.c @@ -7,6 +7,12 @@ #include #include +char const sprites[] = { + 240, 0, + 15, 1, 244, 15, 2, 8, 246, 15, 3, 8, 248, + 15, 1, 8, 10, 245, 15, 2, 8, 247, 15, 3, 8, 249, 11, 0 +}; + struct TEnemy { u8 energy; u8 attack; @@ -15,6 +21,7 @@ struct TEnemy { u8 force; u8 ei; u8 color; + u8 sprite; }; struct TEnemy enemy[3]; @@ -30,10 +37,36 @@ void initEnemy(u8 e, u8 a, u8 d) { enemy[enemies].deffense = d; enemy[enemies].color = enemies + 1; enemy[enemies].x = 7 + (enemies * 2); + enemy[enemies].sprite = 2; enemies++; } } +u8 isFirmware11() { + u8* p = (u8*)0xBAE4; + return (p[0] - p[1]) == (p[2] - p[3]); +} + +void symbolAfter10(u8 c, u16 matrixaddress) { + *((u8*) 0xB294) = c; + *((u8*) 0xB295) = 0xFF; + *((u16*) 0xB296) = matrixaddress; +} + +void symbolAfter11(u8 c, u16 matrixaddress) { + *((u8*) 0xB734) = c; + *((u8*) 0xB735) = 0xFF; + *((u16*) 0xB736) = matrixaddress; +} + +void symbol(u8 c, u8 vals[8]) { + putchar(25); + putchar(c); + for(c = 0; c < 8; c++) { + putchar(vals[c]); + } +} + void pen(u8 color) { putchar(15); putchar(color); @@ -45,10 +78,16 @@ void locate(u8 x, u8 y) { putchar(y); } +void tontof(u8 t) { + putchar(22); + putchar(t); +} + void renderEnemy(u8 i) { - locate(enemy[i].x, 6); - pen(enemy[i].color); - putchar(224); + locate(enemy[i].x, 5); + tontof(1); + printf("%s", &sprites[enemy[i].sprite]); + tontof(0); pen(1); } @@ -56,7 +95,6 @@ u8 FNr(u8 m) { return m-3+(cpct_rand()*7/255); } - void enemyDecide(u8 i) { u8 f; if (enemy[i].x == x+1) { @@ -93,6 +131,21 @@ void initMode() { __endasm; } +u8 const UDG[] = { + /*240*/ 0x3E,0x22,0xE2,0x3E,0x08,0xFF,0x81,0xFF, + /*241*/ 0x3C,0x24,0x3C,0x3C,0x18,0x98,0xE6,0xFE, + /*242*/ 0x9A,0x18,0x18,0x3C,0x3C,0x66,0x66,0xE7, + /*243*/ 0x9C,0x48,0x34,0xFE,0xFE,0x3C,0x54,0x94, + /*244*/ 0x00,0x00,0x2F,0x3E,0x00,0x00,0x00,0x00, + /*245*/ 0x10,0x14,0x94,0x14,0x1C,0x18,0x1E,0x00, + /*246*/ 0x3E,0x7F,0x00,0x01,0x03,0x01,0x02,0x00, + /*247*/ 0x00,0xC0,0x40,0x00,0x00,0x00,0x00,0x36, + /*248*/ 0x00,0x00,0x00,0x00,0x3C,0x2E,0x24,0x3C, + /*249*/ 0x0E,0x0B,0x2B,0x6B,0x43,0x06,0x00,0x00 + + }; + + void main(void) { // Declare variables u8 f = 0; @@ -102,13 +155,21 @@ void main(void) { x = 4; e = 100, a = 30, d = 15, f = 0; + // ASM power! + initMode(); + // Init enemies initEnemy(40, 15, 5); initEnemy(80, 20, 10); initEnemy(100, 25, 15); - // ASM power! - initMode(); + // Enable UDG + if (isFirmware11()) { + symbolAfter11(240, (u16)UDG); + } else { + symbolAfter10(240, (u16)UDG); + } + // symbol(250, UDG); // Let's start! puts("RPG GAME\r\n\r\nPRESS ENTER TO START"); @@ -129,7 +190,7 @@ void main(void) { // RENDER PLAYER locate(x, 6); - putchar(250); + putchar(240); // RENDER ENEMY for (u8 i = 0; i < enemies; i++) {