Yeah... That code to move the ties may be a little ... Buggy
#asm #z80asm #cpc464 #amstrad464
#asm #z80asm #cpc464 #amstrad464
Having fun figuring things out in #z80 (using #cpc464) while frustrating at times, especially if your pushing and popping stuff on and off stack but miss one push or pop them off in wrong order and it takes ages to figure thats what you did wrong. Or that while you can use add HL, you cant use sub hl.
But still making progress. I managed to take 16x16 sprite data. Place 8 spaced copies of it and repeat it over 4 rows. Using loops and calls. Then to load and display 2nd 16 x 32 sprite.
the simple joy i got today when my #z80 code ran correctly and the cpc switched to each mode in turn while printing the ascii characters from 32 to 255 in alternating paper and inks then prompting me to press a key before switching to the next mode.
I mean its so simple in non machine code, a couple of nested for loops and its done.
But the asm is just fun.
I might eventually actually be getting my head around this asm stuff.
#z80 #z80asm #cpc464 #retroprogramming
With that, I'll probably do a bit of cleanup, try to fix a thing or two, and move on to a new adventure!
My goal was never to make the bestest and most accurate emulator. Just to learn and have fun. My "good enough" threshold is very flexible.
What next?
Well I should write a blog entry about the CPC (lol, right!)
I think I need a change of CPU...
Probably the Motorola 6809 (Coco, Vectrex, Thomson, FM-7 anyone?)
One day the 68000 maybe...
3/3
The CPU can only see 64K. The way they implemented extended memory is to have ram modes where you replace pages of the base 64K with pages from extended RAM banks.
First you select a bank (0..7, allowing 512K extended memory + 64K base).
Then you select a RAM Mode (0..7):
Mode 0 is "normal"
Mode 1 maps page 3 of extended RAM
Mode 2 is "all-extended"
Mode 3 is funky (see handy chart)
Modes 4-7 map a single page from ext RAM to page 1
2/3
With sound done (ok I have weird white noise in Gryzor but don't tell anyone), what remains is handling the other CPC models (not the Plus, they're weird).
The CPC664 is almost identical to the 464 but with floppy integrated. The CPC6128 has... 128KB of RAM. Slightly different ROMs.
I had to implement the banking like they did. This required adding a way to swap in or out partial memory blocks ("banks" are 64K, but are swapped in or out in 16K "pages")
1/3
Aha. Came home earlier and this was sitting waiting on me.
Its an #amstrad #cpc464 machine code book. I have a pile of pdf books but theres just something right about coding with an old paperback book to hand.
Wasnt till i typed the caption for the image i realised it was quite bizarre. At first glance i thought it was a robot holding a cpc. As its machine code.
But no, its an outboard motor pushing the cpc across the sea... Which now i think about it, is not that unusual for an 80s book cover.
AY-3-891x (sound chip) datasheet: "There are 16 registers"
*looks at table* OK, so R0 to R15 I guess.
*sees register R16 and R17*
*blinks*
*sees there are no R8-R9*
*blinks*
soo...
Address -> Register name
00 -> R0
01 -> R1
02 -> R2
03 -> R3
04 -> R4
05 -> R5
06 -> R6
07 -> R7 (I see a pattern)
08 -> R10 (wat?)
09 -> R11
10 -> R12
11 -> R13
12 -> R14
13 -> R15
14 -> R16
15 -> R17
General Instrument, what the hell?
I mean, no big deal, but that's just confusing?
Good ol' boring stuff today.
But hey, joystick! :meow_gamer:
now i have my #msx, I have the toshiba hx-10, a rubber key #zxspectrum, a amstrad #cpc464,
I have my #amiga 500, an #atari lynx handheld, oh and an atari 2600jr. though the 2600 is inthe loft and needs some work.
So from being a mostly emulator retro gamer, my little collection of hardware has grown quite a bit in the last 6 months or so. and now I have the MSX I'll be quite happy to wait for my ZX spectrum next 2 to come along.
whats that? cheap #CommodoreC64 on ebay u say?
no! must resist
#msx #zxspectrum #cpc464 #amiga #atari #CommodoreC64
Nope, 'Data' disk sectors are numbered C1 to C9, 'System' disks 41 to 49 (IBM: 1-9).
The system detects the type by looking at the ID of a sector that flies by.
And my floppy class only support raw images with no interleaving and assumes sectors start at 1. And takes a *lot* of shortcuts. Of course it does.
Well, I won't redo everything now, let's just add a 'sector offset' to the geometry for a disk image and it'll be our little secret.
Behold! :meow_floppy: (2/2)
So... floppies.
That sucked.
Fortunately the CPC uses the same floppy controller as the IBM PC so at least I won't have to go through that hell again.
First, we need to load the 'AMSDOS' ROM which provides the support and additional commands such as |DIR. I had to add support for multiple extension ROMs but that wasn't too bad.
Disk images comes in a .DSK format. Ok, I'll add a loader.
Let's connect everything and... what, sectors are not numbered 1-9? (1/2)
Mastodon, we have a keyboard! :meow_bongo_keyboard:
But how, might I hear you ask, since there's no sound chip yet?
Well, who needs that pesky sound chip. The only thing we read from it is the keyboard data. So just skip the chip for now and always return keyboard data when port A is read. Ta-da! :meow_code:
(oh and that Amstrad BASIC looks pretty neat. Like... much better than the Commodore one)
Oh, so the keyboard matrix goes through the IO chip (20% implemented)
*and* the freakin' *sound chip* (0% implemented)
Well, screw you too, CPC464 :meow_angry_intensifies:
Good news is, we now have interrupts. Probably not perfect but enough to get things (like keyboard scanning) moving
It looks like a lot but there's just the bare minimum working. Off the top of my head here's what's missing:
- More video modes
- Interrupt
- PIO chip (8255)
- Keyboard
- Joystick
- Sound chip
- Timing/sync stuff
- Tape
...
erm Parallel port? :noone_cares:
Well, that pesky "job" thing got in the way today so I was just able to squeeze in a bit of time.
I reworked the memory class to allow different blocks on read/write, and added calls to restore and allocate only read|write blocks as needed.
After that, all you need is to swap L and H ROMs in and out on demand (that's done by poking some bits in the gate array).
What this means is that we now have the BASIC ROM loading properly! :meow_blink:
Well that's it for today, looks the same but in colour and with ~10% fewer shortcuts taken!
Today was:
- bitmask class
- proper io address decoding
- pen/ink/palette stuff
- graphics Mode 1 (320x200x4 colors)
- proper CRTC<->RAM address computations (in theory)
Not bad.
eepy now :meow_sleep:
Ohhh we're doing this :meow_bongo_keyboard:
(don't get too excited I'm just scratching the surface... sooooo much to do... and a few shortcuts taken)
#hotkeyemu #amstrad #cpc464 #emulation
Peeps, we have CRT Controller Initialization :fast_meow_party:
The Z80 CPU has 16 bit addresses for IO ports (so possibly 65536 ports if fully decoded but nobody does that).
To make decoding easier, implementations often look only at the 8 lower bits for primary decoding (e.g. ZX Spectrum, ColecoVision)
But the CPC464 uses the high bits (A9-A15). Because *of course* it does.
Well that screws with my things a bit. Again.