Skip to content

Commit 3ffb045

Browse files
committed
stuff
1 parent 1e220c9 commit 3ffb045

File tree

4 files changed

+38
-10
lines changed

4 files changed

+38
-10
lines changed

device.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "devices/buttons.h"
44
#include "devices/eeprom.h"
55
#include "devices/factory_control.h"
6+
#include "devices/lcd.h"
67
#include "devices/led.h"
78
#include "system.h"
89
#include "types.h"
@@ -55,7 +56,6 @@ static const h8_system_preset_t h8_systems[] =
5556
{ 0xd4a05446, 0 },
5657
{
5758
{ 1, H8_DEVICE_LCD, H8_HOOKUP_PORT_1, H8_HOOKUP_SELECT_0, NULL, NULL /* SSU select */ },
58-
{ 1, H8_DEVICE_LCD, H8_HOOKUP_PORT_1, H8_HOOKUP_SELECT_1, NULL, NULL /* 0=cmd 1=data */ },
5959

6060
{ 2, H8_DEVICE_EEPROM_64K, H8_HOOKUP_PORT_1, H8_HOOKUP_SELECT_2, h8_eeprom_read, h8_eeprom_write },
6161

@@ -99,7 +99,7 @@ h8_bool h8_device_init(h8_device_t *device, const h8_device_id type)
9999
device->init = h8_factory_control_init;
100100
break;
101101
case H8_DEVICE_LCD:
102-
device->init = NULL; /** @todo */
102+
device->init = h8_lcd_init;
103103
break;
104104
case H8_DEVICE_LED:
105105
device->init = h8_led_init;

devices/lcd.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,36 @@
44
static const char *name = "128x64 LCD device";
55
static const h8_device_id type = H8_DEVICE_LCD;
66

7+
typedef struct
8+
{
9+
h8_u8 vram[128 * 64];
10+
} h8_lcd_t;
11+
12+
void h8_lcd_read(h8_device_t *device, h8_byte_t *dst)
13+
{
14+
h8_lcd_t *m_lcd = device->device;
15+
16+
/** @todo */
17+
dst->u = m_lcd->vram[0];
18+
}
19+
20+
void h8_lcd_write(h8_device_t *device, h8_byte_t *dst, const h8_byte_t value)
21+
{
22+
h8_lcd_t *m_lcd = device->device;
23+
24+
/** @todo */
25+
m_lcd->vram[0] = value.u;
26+
}
27+
728
void h8_lcd_init(h8_device_t *device)
829
{
930
if (device)
1031
{
32+
h8_lcd_t *m_lcd = h8_dma_alloc(sizeof(h8_lcd_t), TRUE);
33+
34+
device->device = m_lcd;
35+
device->read = h8_lcd_read;
36+
device->write = h8_lcd_write;
1137
device->name = name;
1238
device->type = type;
1339
}

emu.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,13 @@ H8_OUT(pdr1o)
145145
!(system->devices[i].select & value.u))
146146
{
147147
system->ssu_device = &system->devices[i];
148+
printf("Using %s as port 1 device\n", system->devices[i].name);
148149
*byte = value;
149150
return;
150151
}
151152
}
152153
system->ssu_device = NULL;
154+
printf("Couldn't find port 1 device for %u\n", value.u);
153155
*byte = value;
154156
}
155157

@@ -226,6 +228,7 @@ H8_OUT(pdrbo)
226228

227229
H8_IN(sssri)
228230
{
231+
system->vmem.parts.io1.ssu.sssr.flags.tdre = 1;
229232
*byte = system->vmem.parts.io1.ssu.sssr.raw;
230233
}
231234

@@ -1118,8 +1121,8 @@ H8_OP(op01)
11181121
}
11191122
break;
11201123
case 0x80:
1121-
/** @todo SLEEP */
1122-
H8_ERROR(H8_DEBUG_UNIMPLEMENTED_OPCODE)
1124+
/** SLEEP */
1125+
system->sleep = TRUE;
11231126
break;
11241127
case 0xC0:
11251128
H8_ERROR(H8_DEBUG_UNIMPLEMENTED_OPCODE)

system.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,16 +262,15 @@ typedef struct h8_system_t
262262

263263
h8_device_t devices[H8_DEVICES_MAX];
264264

265-
/**
266-
* The number of devices initialized within `devices`
267-
*/
265+
/** The number of devices initialized within `devices` */
268266
unsigned device_count;
269267

270-
/**
271-
* A pointer to the device the SSU is currently interacting with
272-
*/
268+
/** A pointer to the device the SSU is currently interacting with */
273269
h8_device_t *ssu_device;
274270

271+
/** Whether or not SLEEP mode is currently active */
272+
h8_bool sleep;
273+
275274
#if H8_PROFILING
276275
unsigned instructions;
277276
unsigned char reads[0x10000];

0 commit comments

Comments
 (0)