Skip to content

Commit

Permalink
famiyirl: continue on yirl c65 asm
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Gatto <[email protected]>
  • Loading branch information
cosmo-ray committed Nov 10, 2024
1 parent dce714c commit 53234be
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 6 deletions.
16 changes: 16 additions & 0 deletions modules/famiyirl/hello-yirl.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.segment "HEADER"
.byte "YIRL 0"

.segment "DATA"
.byte "hello world"

.segment "RAM"
gamestate: .res 1 ; .rs 1 means reserve one byte of space
gamestate2: .res 1 ; .rs 1 means reserve one byte of space


.segment "CODE"
LDA #$66
LDX #$40
STA gamestate
STA gamestate2
Binary file removed modules/famiyirl/hello-yirl.ybin
Binary file not shown.
30 changes: 25 additions & 5 deletions modules/famiyirl/init.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include <yirl/all.h>

#define YIRL_0_MODE 0
#define NES_MODE 1

#define CARY_FLAG 1
#define ZERO_FLAG (1 << 1)
#define IRQ_DISABLE_FLAG (1 << 2)
Expand Down Expand Up @@ -100,12 +103,12 @@ unsigned char (*get_mem)(uint16_t addr);

void set_mem_yirl(uint16_t addr, char val)
{
printf("set_mem_yirl\n");
printf("set_mem_yirl: at %x val: %x\n", addr, val);
}

void get_mem_yirl(uint16_t addr)
{
printf("get_mem_yirl");
printf("get_mem_yirl at %d - %x\n", addr, addr);
}

void set_mem_nes(uint16_t addr, char val)
Expand Down Expand Up @@ -691,11 +694,18 @@ enum {

void *fy_action(int nbArgs, void **args)
{
Entity *wid = args[0];
Entity *events = args[1];
static int turn_mode;
int mode = yeGetIntAt(wid, "mode");

set_mem = set_mem_nes;
get_mem = get_mem_nes;
if (mode == NES_MODE) {
set_mem = set_mem_nes;
get_mem = get_mem_nes;
} else {
set_mem = set_mem_yirl;
get_mem = get_mem_yirl;
}

if (yevIsKeyDown(events, 'i')) {
printf("fast mode activate\n");
Expand Down Expand Up @@ -758,10 +768,20 @@ void *fy_init(int nbArgs, void **args)
} else {
rom = ygFileToEnt(YRAW_FILE_DATA, "background.nes", NULL);
}

printf("len r: %x - %x\n", yeLen(rom), yeLen(rom) + 0x4020);
yePushBack(wid, rom, "rom");
cartridge = yeGetData(rom);
printf("%s\n", cartridge);
if (!strcmp(cartridge, "NES")) {
printf("NES mode\n");
yeCreateInt(NES_MODE, wid, "mode");
} else if (!strcmp(cartridge, "YIRL 0")) {
printf("YIRL 0 mode\n");
yeCreateInt(YIRL_0_MODE, wid, "mode");
cpu.pc = 0x1000;
} else {
printf("unknow mode %s\n", cartridge);
}
void *ret = ywidNewWidget(wid, "canvas");
for (int i = 0; i < 0x100; ++i) {
switch (i) {
Expand Down
4 changes: 3 additions & 1 deletion modules/famiyirl/yirl-cc64.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ MEMORY {
HDR: start = $0000, size = $1000, type = ro, file = %O, fill = yes, fillval = $00;
RAM: start = $0100, size = $0900, type = rw, file = "", fill = yes, fillval = $ff;
PRG: start = $1000, size = $8000, type = ro, file = %O, fill = yes, fillval = $00;
DTA: start = $9000, size = $7000, type = ro, file = %O, fill = yes, fillval = $00;
}

SEGMENTS {
HEADER: load = HDR, type = ro;
BSS: load = RAM, type = bss;
RAM: load = RAM, type = bss;
CODE: load = PRG, type = ro, start = $1000;
DATA: load = DTA, type = ro, start = $9000;
}

0 comments on commit 53234be

Please sign in to comment.