Reordered devices
This commit is contained in:
parent
256d72e340
commit
92e455141f
86
emulator.c
86
emulator.c
|
@ -37,7 +37,7 @@ SDL_Renderer *gRenderer;
|
||||||
SDL_Texture *gTexture;
|
SDL_Texture *gTexture;
|
||||||
Uint32 *pixels;
|
Uint32 *pixels;
|
||||||
|
|
||||||
Device *devconsole, *devscreen, *devmouse, *devkey, *devsprite, *devctrl;
|
Device *devconsole, *devscreen, *devmouse, *devkey, *devsprite, *devcontroller;
|
||||||
|
|
||||||
#pragma mark - Helpers
|
#pragma mark - Helpers
|
||||||
|
|
||||||
|
@ -187,12 +187,6 @@ domouse(SDL_Event *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
dokey(SDL_Event *event)
|
|
||||||
{
|
|
||||||
(void)event;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
doctrl(SDL_Event *event, int z)
|
doctrl(SDL_Event *event, int z)
|
||||||
{
|
{
|
||||||
|
@ -209,18 +203,16 @@ doctrl(SDL_Event *event, int z)
|
||||||
case SDLK_LEFT: flag = 0x40; break;
|
case SDLK_LEFT: flag = 0x40; break;
|
||||||
case SDLK_RIGHT: flag = 0x80; break;
|
case SDLK_RIGHT: flag = 0x80; break;
|
||||||
}
|
}
|
||||||
setflag(&devctrl->mem[0], flag, z);
|
setflag(&devcontroller->mem[0], flag, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Devices
|
#pragma mark - Devices
|
||||||
|
|
||||||
Uint8
|
Uint8
|
||||||
consoler(Device *d, Memory *m, Uint8 b)
|
defaultrw(Device *d, Memory *m, Uint8 b)
|
||||||
{
|
{
|
||||||
(void)b;
|
|
||||||
(void)d;
|
|
||||||
(void)m;
|
(void)m;
|
||||||
return 0;
|
return d->mem[b];
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint8
|
Uint8
|
||||||
|
@ -235,7 +227,7 @@ consolew(Device *d, Memory *m, Uint8 b)
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint8
|
Uint8
|
||||||
ppur(Device *d, Memory *m, Uint8 b)
|
screenr(Device *d, Memory *m, Uint8 b)
|
||||||
{
|
{
|
||||||
switch(b) {
|
switch(b) {
|
||||||
case 0: return (WIDTH >> 8) & 0xff;
|
case 0: return (WIDTH >> 8) & 0xff;
|
||||||
|
@ -243,11 +235,12 @@ ppur(Device *d, Memory *m, Uint8 b)
|
||||||
case 2: return (HEIGHT >> 8) & 0xff;
|
case 2: return (HEIGHT >> 8) & 0xff;
|
||||||
case 3: return HEIGHT & 0xff;
|
case 3: return HEIGHT & 0xff;
|
||||||
}
|
}
|
||||||
|
(void)m;
|
||||||
return d->mem[b];
|
return d->mem[b];
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint8
|
Uint8
|
||||||
ppuw(Device *d, Memory *m, Uint8 b)
|
screenw(Device *d, Memory *m, Uint8 b)
|
||||||
{
|
{
|
||||||
d->mem[d->len++] = b;
|
d->mem[d->len++] = b;
|
||||||
if(d->len > 5) {
|
if(d->len > 5) {
|
||||||
|
@ -259,17 +252,12 @@ ppuw(Device *d, Memory *m, Uint8 b)
|
||||||
redraw(pixels);
|
redraw(pixels);
|
||||||
d->len = 0;
|
d->len = 0;
|
||||||
}
|
}
|
||||||
|
(void)m;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint8
|
Uint8
|
||||||
ppusr(Device *d, Memory *m, Uint8 b)
|
spritew(Device *d, Memory *m, Uint8 b)
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Uint8
|
|
||||||
ppusw(Device *d, Memory *m, Uint8 b)
|
|
||||||
{
|
{
|
||||||
d->mem[d->len++] = b;
|
d->mem[d->len++] = b;
|
||||||
if(d->len > 6) {
|
if(d->len > 6) {
|
||||||
|
@ -284,50 +272,6 @@ ppusw(Device *d, Memory *m, Uint8 b)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint8
|
|
||||||
mouser(Device *d, Memory *m, Uint8 b)
|
|
||||||
{
|
|
||||||
return d->mem[b];
|
|
||||||
}
|
|
||||||
|
|
||||||
Uint8
|
|
||||||
mousew(Device *d, Memory *m, Uint8 b)
|
|
||||||
{
|
|
||||||
(void)d;
|
|
||||||
(void)b;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Uint8
|
|
||||||
keyr(Device *d, Memory *m, Uint8 b)
|
|
||||||
{
|
|
||||||
(void)d;
|
|
||||||
(void)b;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Uint8
|
|
||||||
keyw(Device *d, Memory *m, Uint8 b)
|
|
||||||
{
|
|
||||||
(void)d;
|
|
||||||
(void)b;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Uint8
|
|
||||||
ctrlr(Device *d, Memory *m, Uint8 b)
|
|
||||||
{
|
|
||||||
return d->mem[b];
|
|
||||||
}
|
|
||||||
|
|
||||||
Uint8
|
|
||||||
ctrlw(Device *d, Memory *m, Uint8 b)
|
|
||||||
{
|
|
||||||
(void)d;
|
|
||||||
(void)b;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - Generics
|
#pragma mark - Generics
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -378,12 +322,12 @@ main(int argc, char **argv)
|
||||||
if(!init())
|
if(!init())
|
||||||
return error("Init", "Failed");
|
return error("Init", "Failed");
|
||||||
|
|
||||||
devconsole = portuxn(&u, "console", consoler, consolew);
|
devconsole = portuxn(&u, "console", defaultrw, consolew);
|
||||||
devscreen = portuxn(&u, "ppu", ppur, ppuw);
|
devscreen = portuxn(&u, "screen", screenr, screenw);
|
||||||
devmouse = portuxn(&u, "mouse", mouser, mousew);
|
devsprite = portuxn(&u, "sprite", defaultrw, spritew);
|
||||||
devkey = portuxn(&u, "key", keyr, keyw);
|
devcontroller = portuxn(&u, "controller", defaultrw, defaultrw);
|
||||||
devsprite = portuxn(&u, "ppu-sprite", ppusr, ppusw);
|
devkey = portuxn(&u, "key", defaultrw, consolew);
|
||||||
devctrl = portuxn(&u, "ctrl", ctrlr, ctrlw);
|
devmouse = portuxn(&u, "mouse", defaultrw, defaultrw);
|
||||||
|
|
||||||
start(&u);
|
start(&u);
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
|0100 @RESET
|
|0100 @RESET
|
||||||
|
|
||||||
#05 =dev/r ( set dev/read to ctrl )
|
#03 =dev/r ( set dev/read to controller )
|
||||||
#04 =dev/w ( set dev/write to ppu-sprite )
|
#02 =dev/w ( set dev/write to sprite )
|
||||||
#0080 =x #0040 =y ( origin )
|
#0080 =x #0040 =y ( origin )
|
||||||
#01 ,cursor_icn ~x ~y ,putsprite JSR ( draw sprite )
|
#01 ,cursor_icn ~x ~y ,putsprite JSR ( draw sprite )
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|0100 @RESET
|
|0100 @RESET
|
||||||
|
|
||||||
( set dev/write to screen )
|
( set dev/write to screen )
|
||||||
#01 ,dev/w STR
|
#01 =dev/w ( set dev/write to sprite )
|
||||||
|
|
||||||
#01 ,color STR
|
#01 ,color STR
|
||||||
( fill rect x y w h )
|
( fill rect x y w h )
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
|0100 @RESET
|
|0100 @RESET
|
||||||
|
|
||||||
|
#00 =dev/w ( set dev/write to sprite )
|
||||||
,string ( add string pointer to stack )
|
,string ( add string pointer to stack )
|
||||||
@loop
|
@loop
|
||||||
DUP2 LDR IOW ( write pointer value to console )
|
DUP2 LDR IOW ( write pointer value to console )
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|0100 @RESET
|
|0100 @RESET
|
||||||
|
|
||||||
( set dev/write to screen )
|
( set dev/write to screen )
|
||||||
#01 ,dev/w STR
|
#01 =dev/w ( set dev/write to sprite )
|
||||||
|
|
||||||
( positive )
|
( positive )
|
||||||
#01 ,color STR
|
#01 ,color STR
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
|0100 @RESET
|
|0100 @RESET
|
||||||
|
|
||||||
#02 =dev/r ( set dev/read mouse#02 )
|
#05 =dev/r ( set dev/read mouse#02 )
|
||||||
#01 =dev/w ( set dev/write screen#01 )
|
#01 =dev/w ( set dev/write screen#01 )
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|0100 @RESET
|
|0100 @RESET
|
||||||
|
|
||||||
#01 =dev/w ( set dev/write to screen )
|
#01 =dev/w ( set dev/write to screen )
|
||||||
#04 =dev/w ( set dev/write to ppu-sprite )
|
#02 =dev/w ( set dev/write to sprite )
|
||||||
|
|
||||||
#00 ,star_icn #0041 #0041 ,putsprite JSR
|
#00 ,star_icn #0041 #0041 ,putsprite JSR
|
||||||
#00 ,star_icn #0031 #0021 ,putsprite JSR
|
#00 ,star_icn #0031 #0021 ,putsprite JSR
|
||||||
|
|
Loading…
Reference in New Issue