1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
/*
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely.
*/
/* Simple program: Move N sprites around on the screen as fast as possible */
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#ifdef __EMSCRIPTEN__
#include <emscripten/emscripten.h>
#endif
#include "SDL_test_common.h"
static SDLTest_CommonState *state;
typedef struct {
SDL_Window *window;
SDL_Renderer *renderer;
SDL_Texture *background;
SDL_Texture *sprite;
SDL_Rect sprite_rect;
int scale_direction;
} DrawState;
DrawState *drawstates;
int done;
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
static void
quit(int rc)
{
SDLTest_CommonQuit(state);
exit(rc);
}
SDL_Texture *
LoadTexture(SDL_Renderer *renderer, const char *file, // license:LGPL-2.1+
// copyright-holders:Angelo Salese
/*****************************************************************************
Casio Loopy (c) 1995 Casio
skeleton driver
TODO:
- Identify what actually is the NEC CDT-109 CPU, it should contain a program
controller for the thermal printer device
Note:
- just a placeholder for any HW discovery, until we decap/trojan the BIOS,
the idea is to understand the HW enough to extract the SH-1 internal BIOS
data via a trojan;
ASM notes:
- first vector is almost certainly VBR value.
- [VBR + 0x2c] irq for i/o?
- [VBR + 0x140] points to an internal BIOS routine, at 0x6238
(Nigaoe Artist has a direct 0x648c instead)
- 0x0604 is probably a BRA -2 / NOP (some games puts that as a null irq vector)
- Nigaoe Artist jumps to 0x668 at some point.
===============================================================================
Casio Loopy PCB Layout
----------------------
JCM631-MA1M C
|---------------------------------------------------------|
| CB CC CD CE CF CG |
|--| |
| BA10339F |
|--| 15218 |--| CXA1645M CH|
| | | A1603C |
| 15218 | | |
| | | |
|BIOS.LSI352| | |
| | | 21MHz |
| |--------|| | |------| SW1 |
| |NEC || | |SH7021| |----------| |
| |CDT109 ||CA| | | | | |
| | || | |------| |CASIO | |
| |--------|| | |RH-7500 | |
| | | |5C315 | |--|
| |-------| | | | | |
| |CASIO | | | |----------| |--|
| |RH-7501| | | HM514260 |
| |5C350 | | | HM62256 |
| |-------| | | |
| 6379 |--| SW301 HM62256 /
|--------| HM538123 /
| /
| /
|--------------------------------------------/
Notes:
Connectors
----------
CA - Cartridge connector
CB - Power Input connector
CC - Composite Video and Audio Out connector
CD - Printer Cassette Motor connector
CE - Printer Data connector
CF - Printer Head connector
CG - Paper Sensor connector
CH - Joystick connector
Connectors on the back of the main unit include RCA audio (left/right), RCA composite video,
24V DC power input and contrast knob.
On top of the main unit, there is a reset button, on/off slide switch, a big eject button, a
button to cut off stickers after they're printed, a button to open the hatch where the sticker
cassette is located and a red LED for power.
IC's
----
BIOS2.LSI352- Hitachi HN62434 512k x8 (4MBit) maskROM (SOP40)
CDT-109 - NEC CDT109 (QFP120). This is some kind of CPU, the package looks a bit
like a V60. The BIOS is tied directly to it.
RH-7500 - Casio RH-7500 5C315 (QFP208). This is the graphics generator chip.
RH-7501 - Casio RH-7501 5C350 (QFP64). This is probably the sound chip.
SH7021 - Hitachi HD6437021TE20 SuperH RISC Engine SH-2A CPU with 32k internal maskROM (TQFP100)
The internal ROM (BIOS1) is not dumped. A SH-2A software programming manual is available here...
http://documentation.renesas.com/eng/products/mpumcu/rej09b0051_sh2a.pdf
CXA1645M - Sony CXA1645M RGB Encoder (RGB -> Composite Video) (SOIC24)
A1603C - NEC uPA1603C Compound Field Effect Power Transistor Array (DIP16)
HM514260 - Hitachi HM514260 256k x 16 DRAM (SOJ40)
HM538123 - Hitachi HM538123 128k x8 multi-port Video DRAM with 256-word x8 serial access memory (SOJ40)
HM62256 - Hitachi HM62256 32k x8 SRAM (SOP28)
BA10339F - Rohm BA10339F Quad Comparitor (SOIC14)
6379 - NEC uPD6379 2-channel 16-bit D/A convertor for digital audio signal demodulation (SOIC8)
15218 - Rohm BA15218 Dual High Slew Rate, Low Noise Operational Amplifier (SOIC8)
Other
-----
SW1 - Reset Switch
SW301 - ON/OFF Slide Switch
Carts
-----
There are reports of 11 existing carts.
Only 6 are available so far.
XK-401: Anime Land
XK-402: HARIHARI Seal Paradise
XK-403: Dream Change
XK-404: Nigaoe Artist
XK-501: Wanwan Aijou Monogatari
XK-502: PC Collection
The rest are not dumped yet.....
Lupiton's Wonder Palette
Magical Shop
Chakra-kun no Omajinai Paradise
XK-503: Little Romance
XK-504: I want a room in Loopy Town
Inside the carts
----------------
Carts 401 - 404:
PCB 'JCM632-AN1M C'
1x 16M maskROM (SOP44)
1x 8k x8 SRAM (SOP28)
1x 3V coin battery (CR2032)
Cart 501:
PCB 'Z544-1 A240427-1'
1x 16M maskROM (SOP44)
1x 8k x8 SRAM (SOP28)
1x OKI MSM6653A Voice Synthesis IC with 544Kbits internal maskROM (SOP24)
1x Rohm BA15218 High Slew Rate, Low Noise, Dual Operational Amplifier (SOIC8)
1x 74HC273 logic chip
1x 3V coin battery (CR2032)
Cart 502:
PCB 'Z545-1 A240570-1'
1x 16M maskROM (SOP44)
1x 32k x8 SRAM (SOP28)
1x 74HC00 logic chip
1x 3V coin battery (CR2032)
******************************************************************************/
#include "emu.h"
#include "cpu/sh/sh2.h"
#include "bus/generic/slot.h"
#include "bus/generic/carts.h"
#include "emupal.h"
#include "screen.h"
#include "softlist.h"
#include "speaker.h"
class casloopy_state : public driver_device
{
public:
casloopy_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_bios_rom(*this, "bios_rom"),
m_vregs(*this, "vregs"),
m_maincpu(*this, "maincpu"),
m_cart(*this, "cartslot"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette"),
m_screen(*this, "screen") { }
void casloopy(machine_config &config);
void init_casloopy();
protected:
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void video_start() override;
private:
required_shared_ptr<uint32_t> m_bios_rom;
required_shared_ptr<uint32_t> m_vregs;
required_device<cpu_device> m_maincpu;
required_device<generic_slot_device> m_cart;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
required_device<screen_device> m_screen;
std::unique_ptr<uint16_t[]> m_paletteram;
std::unique_ptr<uint8_t[]> m_vram;
std::unique_ptr<uint8_t[]> m_bitmap_vram;
uint16_t sh7021_regs[0x100];
int m_gfx_index;
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
DECLARE_READ16_MEMBER(vregs_r);
DECLARE_WRITE16_MEMBER(vregs_w);
DECLARE_READ16_MEMBER(pal_r);
DECLARE_WRITE16_MEMBER(pal_w);
DECLARE_READ8_MEMBER(vram_r);
DECLARE_WRITE8_MEMBER(vram_w);
DECLARE_READ32_MEMBER(cart_r);
DECLARE_READ16_MEMBER(sh7021_r);
DECLARE_WRITE16_MEMBER(sh7021_w);
DECLARE_READ8_MEMBER(bitmap_r);
DECLARE_WRITE8_MEMBER(bitmap_w);
DECLARE_DEVICE_IMAGE_LOAD_MEMBER(cart_load);
void casloopy_map(address_map &map);
void casloopy_sub_map(address_map &map);
};
static const gfx_layout casloopy_4bpp_layout =
{
8,8,
0x10000/32,
4,
{ STEP4(0, 1) },
{ STEP8(0, 4) },
{ STEP8(0, 4*8) },
4*8*8
};
static const gfx_layout casloopy_8bpp_layout =
{
8,8,
0x10000/64,
8,
{ STEP8(0, 1) },
{ STEP8(0, 8) },
{ STEP8(0, 8*8) },
8*8*8
};
void casloopy_state::video_start()
{
/* TODO: proper sizes */
m_paletteram = make_unique_clear<uint16_t[]>(0x1000);
m_vram = make_unique_clear<uint8_t[]>(0x10000);
m_bitmap_vram = make_unique_clear<uint8_t[]>(0x20000);
for (m_gfx_index = 0; m_gfx_index < MAX_GFX_ELEMENTS; m_gfx_index++)
if (m_gfxdecode->gfx(m_gfx_index) == nullptr)
break;
for(int i=0;i<0x10000;i++)
m_vram[i] = i & 0xff;
m_gfxdecode->set_gfx(m_gfx_index, std::make_unique<gfx_element>(m_palette, casloopy_4bpp_layout, m_vram.get(), 0, 0x10, 0));
m_gfxdecode->set_gfx(m_gfx_index+1, std::make_unique<gfx_element>(m_palette, casloopy_8bpp_layout, m_vram.get(), 0, 1, 0));
}
uint32_t casloopy_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
gfx_element *gfx = m_gfxdecode->gfx(m_gfx_index);
int x,y;
int count;
static int test;
if(machine().input(
|