Skip to content

Commit

Permalink
* New C file for AGC04
Browse files Browse the repository at this point in the history
 * Added User Defined Characters
 * Emulating Symbol After and Symbol of Amstrad
  • Loading branch information
heclinares committed Aug 30, 2019
1 parent 98bc96b commit 37102b0
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 7 deletions.
Binary file modified c/rpg.cdt
Binary file not shown.
Binary file modified c/rpg.dsk
Binary file not shown.
Binary file modified c/rpg.sna
Binary file not shown.
75 changes: 68 additions & 7 deletions c/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
#include <cpctelera.h>
#include <stdio.h>

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;
Expand All @@ -15,6 +21,7 @@ struct TEnemy {
u8 force;
u8 ei;
u8 color;
u8 sprite;
};

struct TEnemy enemy[3];
Expand All @@ -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);
Expand All @@ -45,18 +78,23 @@ 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);
}

u8 FNr(u8 m) {
return m-3+(cpct_rand()*7/255);
}


void enemyDecide(u8 i) {
u8 f;
if (enemy[i].x == x+1) {
Expand Down Expand Up @@ -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;
Expand All @@ -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");
Expand All @@ -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++) {
Expand Down

0 comments on commit 37102b0

Please sign in to comment.