| ... | ... |
@@ -144,52 +144,52 @@ screen_dei(Uint8 *d, Uint8 port) |
| 144 | 144 |
} |
| 145 | 145 |
|
| 146 | 146 |
void |
| 147 |
-screen_deo(Device *d, Uint8 port) |
|
| 147 |
+screen_deo(Uint8 *ram, Uint8 *d, Uint8 port) |
|
| 148 | 148 |
{
|
| 149 | 149 |
switch(port) {
|
| 150 | 150 |
case 0x3: |
| 151 | 151 |
if(!FIXED_SIZE) {
|
| 152 | 152 |
Uint16 w; |
| 153 |
- DEVPEEK16(w, 0x2); |
|
| 153 |
+ PEKDEV(w, 0x2); |
|
| 154 | 154 |
screen_resize(&uxn_screen, clamp(w, 1, 1024), uxn_screen.height); |
| 155 | 155 |
} |
| 156 | 156 |
break; |
| 157 | 157 |
case 0x5: |
| 158 | 158 |
if(!FIXED_SIZE) {
|
| 159 | 159 |
Uint16 h; |
| 160 |
- DEVPEEK16(h, 0x4); |
|
| 160 |
+ PEKDEV(h, 0x4); |
|
| 161 | 161 |
screen_resize(&uxn_screen, uxn_screen.width, clamp(h, 1, 1024)); |
| 162 | 162 |
} |
| 163 | 163 |
break; |
| 164 | 164 |
case 0xe: {
|
| 165 | 165 |
Uint16 x, y; |
| 166 |
- Uint8 layer = d->dat[0xe] & 0x40; |
|
| 167 |
- DEVPEEK16(x, 0x8); |
|
| 168 |
- DEVPEEK16(y, 0xa); |
|
| 169 |
- screen_write(&uxn_screen, layer ? &uxn_screen.fg : &uxn_screen.bg, x, y, d->dat[0xe] & 0x3); |
|
| 170 |
- if(d->dat[0x6] & 0x01) DEVPOKE16(0x8, x + 1); /* auto x+1 */ |
|
| 171 |
- if(d->dat[0x6] & 0x02) DEVPOKE16(0xa, y + 1); /* auto y+1 */ |
|
| 166 |
+ Uint8 layer = d[0xe] & 0x40; |
|
| 167 |
+ PEKDEV(x, 0x8); |
|
| 168 |
+ PEKDEV(y, 0xa); |
|
| 169 |
+ screen_write(&uxn_screen, layer ? &uxn_screen.fg : &uxn_screen.bg, x, y, d[0xe] & 0x3); |
|
| 170 |
+ if(d[0x6] & 0x01) POKDEV(0x8, x + 1); /* auto x+1 */ |
|
| 171 |
+ if(d[0x6] & 0x02) POKDEV(0xa, y + 1); /* auto y+1 */ |
|
| 172 | 172 |
break; |
| 173 | 173 |
} |
| 174 | 174 |
case 0xf: {
|
| 175 | 175 |
Uint16 x, y, dx, dy, addr; |
| 176 |
- Uint8 i, n, twobpp = !!(d->dat[0xf] & 0x80); |
|
| 177 |
- Layer *layer = (d->dat[0xf] & 0x40) ? &uxn_screen.fg : &uxn_screen.bg; |
|
| 178 |
- DEVPEEK16(x, 0x8); |
|
| 179 |
- DEVPEEK16(y, 0xa); |
|
| 180 |
- DEVPEEK16(addr, 0xc); |
|
| 181 |
- n = d->dat[0x6] >> 4; |
|
| 182 |
- dx = (d->dat[0x6] & 0x01) << 3; |
|
| 183 |
- dy = (d->dat[0x6] & 0x02) << 2; |
|
| 176 |
+ Uint8 i, n, twobpp = !!(d[0xf] & 0x80); |
|
| 177 |
+ Layer *layer = (d[0xf] & 0x40) ? &uxn_screen.fg : &uxn_screen.bg; |
|
| 178 |
+ PEKDEV(x, 0x8); |
|
| 179 |
+ PEKDEV(y, 0xa); |
|
| 180 |
+ PEKDEV(addr, 0xc); |
|
| 181 |
+ n = d[0x6] >> 4; |
|
| 182 |
+ dx = (d[0x6] & 0x01) << 3; |
|
| 183 |
+ dy = (d[0x6] & 0x02) << 2; |
|
| 184 | 184 |
if(addr > 0x10000 - ((n + 1) << (3 + twobpp))) |
| 185 | 185 |
return; |
| 186 | 186 |
for(i = 0; i <= n; i++) {
|
| 187 |
- screen_blit(&uxn_screen, layer, x + dy * i, y + dx * i, &d->u->ram[addr], d->dat[0xf] & 0xf, d->dat[0xf] & 0x10, d->dat[0xf] & 0x20, twobpp); |
|
| 188 |
- addr += (d->dat[0x6] & 0x04) << (1 + twobpp); |
|
| 187 |
+ screen_blit(&uxn_screen, layer, x + dy * i, y + dx * i, &ram[addr], d[0xf] & 0xf, d[0xf] & 0x10, d[0xf] & 0x20, twobpp); |
|
| 188 |
+ addr += (d[0x6] & 0x04) << (1 + twobpp); |
|
| 189 | 189 |
} |
| 190 |
- DEVPOKE16(0xc, addr); /* auto addr+length */ |
|
| 191 |
- DEVPOKE16(0x8, x + dx); /* auto x+8 */ |
|
| 192 |
- DEVPOKE16(0xa, y + dy); /* auto y+8 */ |
|
| 190 |
+ POKDEV(0xc, addr); /* auto addr+length */ |
|
| 191 |
+ POKDEV(0x8, x + dx); /* auto x+8 */ |
|
| 192 |
+ POKDEV(0xa, y + dy); /* auto y+8 */ |
|
| 193 | 193 |
break; |
| 194 | 194 |
} |
| 195 | 195 |
} |
| ... | ... |
@@ -32,5 +32,5 @@ void screen_redraw(UxnScreen *p, Uint32 *pixels); |
| 32 | 32 |
void screen_mono(UxnScreen *p, Uint32 *pixels); |
| 33 | 33 |
|
| 34 | 34 |
Uint8 screen_dei(Uint8 *d, Uint8 port); |
| 35 |
-void screen_deo(Device *d, Uint8 port); |
|
| 35 |
+void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port); |
|
| 36 | 36 |
int clamp(int val, int min, int max); |
| ... | ... |
@@ -37,8 +37,8 @@ console_input(Uxn *u, char c) |
| 37 | 37 |
static void |
| 38 | 38 |
console_deo(Uint8 *d, Uint8 port) |
| 39 | 39 |
{
|
| 40 |
- FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr : |
|
| 41 |
- 0; |
|
| 40 |
+ FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr |
|
| 41 |
+ : 0; |
|
| 42 | 42 |
if(fd) {
|
| 43 | 43 |
fputc(d[port], fd); |
| 44 | 44 |
fflush(fd); |
| ... | ... |
@@ -200,7 +200,7 @@ emu_dei(Uxn *u, Uint8 addr) |
| 200 | 200 |
{
|
| 201 | 201 |
Uint8 p = addr & 0x0f, d = addr & 0xf0; |
| 202 | 202 |
switch(d) {
|
| 203 |
- case 0x20: return screen_dei(&u->dev[d], p); |
|
| 203 |
+ case 0x20: return screen_dei(&u->dev[d], p); |
|
| 204 | 204 |
case 0xa0: return file_dei(0, &u->dev[d], p); |
| 205 | 205 |
case 0xb0: return file_dei(1, &u->dev[d], p); |
| 206 | 206 |
case 0xc0: return datetime_dei(&u->dev[d], p); |
| ... | ... |
@@ -212,7 +212,7 @@ emu_dei(Uxn *u, Uint8 addr) |
| 212 | 212 |
static void |
| 213 | 213 |
emu_deo(Uxn *u, Uint8 addr, Uint8 v) |
| 214 | 214 |
{
|
| 215 |
-Uint8 p = addr & 0x0f, d = addr & 0xf0; |
|
| 215 |
+ Uint8 p = addr & 0x0f, d = addr & 0xf0; |
|
| 216 | 216 |
Uint16 mask = 0x1 << (d >> 4); |
| 217 | 217 |
u->dev[addr] = v; |
| 218 | 218 |
switch(d) {
|
| ... | ... |
@@ -222,7 +222,7 @@ Uint8 p = addr & 0x0f, d = addr & 0xf0; |
| 222 | 222 |
screen_palette(&uxn_screen, &u->dev[0x8]); |
| 223 | 223 |
break; |
| 224 | 224 |
case 0x10: console_deo(&u->dev[d], p); break; |
| 225 |
- /* case 0x20: screen_deo(u->ram, &u->dev[d], p); break; */ |
|
| 225 |
+ case 0x20: screen_deo(u->ram, &u->dev[d], p); break; |
|
| 226 | 226 |
case 0xa0: file_deo(0, u->ram, &u->dev[d], p); break; |
| 227 | 227 |
case 0xb0: file_deo(1, u->ram, &u->dev[d], p); break; |
| 228 | 228 |
} |
| ... | ... |
@@ -406,22 +406,22 @@ handle_events(Uxn *u) |
| 406 | 406 |
} |
| 407 | 407 |
/* Mouse */ |
| 408 | 408 |
else if(event.type == SDL_MOUSEMOTION) |
| 409 |
- mouse_pos(u, u->devold[9].dat, clamp(event.motion.x - PAD, 0, uxn_screen.width - 1), clamp(event.motion.y - PAD, 0, uxn_screen.height - 1)); |
|
| 409 |
+ mouse_pos(u, &u->dev[0x90], clamp(event.motion.x - PAD, 0, uxn_screen.width - 1), clamp(event.motion.y - PAD, 0, uxn_screen.height - 1)); |
|
| 410 | 410 |
else if(event.type == SDL_MOUSEBUTTONUP) |
| 411 |
- mouse_up(u, u->devold[9].dat, SDL_BUTTON(event.button.button)); |
|
| 411 |
+ mouse_up(u, &u->dev[0x90], SDL_BUTTON(event.button.button)); |
|
| 412 | 412 |
else if(event.type == SDL_MOUSEBUTTONDOWN) |
| 413 |
- mouse_down(u, u->devold[9].dat, SDL_BUTTON(event.button.button)); |
|
| 413 |
+ mouse_down(u, &u->dev[0x90], SDL_BUTTON(event.button.button)); |
|
| 414 | 414 |
else if(event.type == SDL_MOUSEWHEEL) |
| 415 |
- mouse_scroll(u, u->devold[9].dat, event.wheel.x, event.wheel.y); |
|
| 415 |
+ mouse_scroll(u, &u->dev[0x90], event.wheel.x, event.wheel.y); |
|
| 416 | 416 |
/* Controller */ |
| 417 | 417 |
else if(event.type == SDL_TEXTINPUT) |
| 418 |
- controller_key(u, u->devold[8].dat, event.text.text[0]); |
|
| 418 |
+ controller_key(u, &u->dev[0x80], event.text.text[0]); |
|
| 419 | 419 |
else if(event.type == SDL_KEYDOWN) {
|
| 420 | 420 |
int ksym; |
| 421 | 421 |
if(get_key(&event)) |
| 422 |
- controller_key(u, u->devold[8].dat, get_key(&event)); |
|
| 422 |
+ controller_key(u, &u->dev[0x80], get_key(&event)); |
|
| 423 | 423 |
else if(get_button(&event)) |
| 424 |
- controller_down(u, u->devold[8].dat, get_button(&event)); |
|
| 424 |
+ controller_down(u, &u->dev[0x80], get_button(&event)); |
|
| 425 | 425 |
else |
| 426 | 426 |
do_shortcut(u, &event); |
| 427 | 427 |
ksym = event.key.keysym.sym; |
| ... | ... |
@@ -429,17 +429,17 @@ handle_events(Uxn *u) |
| 429 | 429 |
return 1; |
| 430 | 430 |
} |
| 431 | 431 |
} else if(event.type == SDL_KEYUP) |
| 432 |
- controller_up(u, u->devold[8].dat, get_button(&event)); |
|
| 432 |
+ controller_up(u, &u->dev[0x80], get_button(&event)); |
|
| 433 | 433 |
else if(event.type == SDL_JOYAXISMOTION) {
|
| 434 | 434 |
Uint8 vec = get_vector_joystick(&event); |
| 435 | 435 |
if(!vec) |
| 436 |
- controller_up(u, u->devold[8].dat, (3 << (!event.jaxis.axis * 2)) << 4); |
|
| 436 |
+ controller_up(u, &u->dev[0x80], (3 << (!event.jaxis.axis * 2)) << 4); |
|
| 437 | 437 |
else |
| 438 |
- controller_down(u, u->devold[8].dat, (1 << ((vec + !event.jaxis.axis * 2) - 1)) << 4); |
|
| 438 |
+ controller_down(u, &u->dev[0x80], (1 << ((vec + !event.jaxis.axis * 2) - 1)) << 4); |
|
| 439 | 439 |
} else if(event.type == SDL_JOYBUTTONDOWN) |
| 440 |
- controller_down(u, u->devold[8].dat, get_button_joystick(&event)); |
|
| 440 |
+ controller_down(u, &u->dev[0x80], get_button_joystick(&event)); |
|
| 441 | 441 |
else if(event.type == SDL_JOYBUTTONUP) |
| 442 |
- controller_up(u, u->devold[8].dat, get_button_joystick(&event)); |
|
| 442 |
+ controller_up(u, &u->dev[0x80], get_button_joystick(&event)); |
|
| 443 | 443 |
/* Console */ |
| 444 | 444 |
else if(event.type == stdin_event) |
| 445 | 445 |
console_input(u, event.cbutton.button); |