gertk
Posts: 52
Joined: Mon Aug 29, 2011 9:08 am

Re: Bare Metal ZX81 emulator

Tue Nov 13, 2012 6:53 am

poglad wrote:That's true, although traditionally it was never done that way... I seem to recall always having to write little machine code things in a REM statement to do the OUT instruction! :lol: Whichever memory locations you choose, they won't be available for RAM any more (obviously). If you were cunning, you would map it to ports including 31, and 5 of the GPIO pins would "just happen" to provide a Kempston joystick interface hahaha...
Since the real ZX81 was not designed to take more than 16k there is still room in the memory map to place some IO, for testing my joystick interface on the mbed version I had placed a pseudo register at 0xFFFF. Later on I changed the joystick interface to be ZXpand compatible. I can use 5 GPIO pins for a joystick interface, just need to make a cable.

On testing some HiRes demo's I found the '25th anniversary' demo runs but the screen is not properly synced. Also a (famous) demo called GUUST FLATER seems to run but the whole screen is compressed into the top 4 scanlines or so :) There must be some trickery going there to fool the original ULA into not updating the scanline counter.

I now have a 64usec timer triggering each scanline but the instructions are executed way faster than the original Z80 so I need to count them to make sure there are no more than 'x' instructions/NOPs per scanline.

User avatar
poglad
Posts: 100
Joined: Tue Jul 31, 2012 8:47 am
Location: Aberdeen, Scotland
Contact: Website

Re: Bare Metal ZX81 emulator

Wed Nov 14, 2012 12:26 pm

Sounds like good progress, keep us informed! :)

gertk
Posts: 52
Joined: Mon Aug 29, 2011 9:08 am

Re: Bare Metal ZX81 emulator

Sun Nov 18, 2012 3:05 pm

Added ZXpand compatible joystick interface on GPIO pins:
very_small_2012-11-18 15.54.01.jpg
Joystick connector mounted
very_small_2012-11-18 15.54.01.jpg (43.8 KiB) Viewed 2077 times
Initialization:

Code: Select all

// initialize IO pins for joystick
void joystick_init()
{
	// set pins to input
	SetPinFunction(21,GPIO_INPUT);	// Fire button
	SetPinFunction(22,GPIO_INPUT);	// Right
	SetPinFunction(23,GPIO_INPUT);	// Left
	SetPinFunction(24,GPIO_INPUT);	// Down
	SetPinFunction(25,GPIO_INPUT);	// Up
	
	// enable pullups on these pins
	PUT32(GPPUD,GPIO_ENABLE_PULLUP); // pull up mode set
	wait(1);			 // wait a bit
	PUT32(GPPUDCLK0,(0xf8 << 18));	 // write for pins 21-25
	wait(1);			 // should be done now
}

gertk
Posts: 52
Joined: Mon Aug 29, 2011 9:08 am

Re: Bare Metal ZX81 emulator

Sun Nov 18, 2012 8:47 pm

Tried to link in the libcsud.a library to get USB keyboard input but it slows down the ZX81 keyboard/display routine too much. Alas I can not look under the hood to see which part of the library is slowing things down (Probably because it is polling and not interrupt driven). I did manage to get valid keypresses from the USB keyboard though.

I re-used the keyboard.s routine and included the USB initialization in my main.c. I had to rename the keyboard.s to zxkeyboard.s otherwise it got assembled before vectors.s and the vectors were at the wrong place. (How do you select the order for that ? I tried .org 0x8000 in vectors.s but it did not make a difference)

User avatar
poglad
Posts: 100
Joined: Tue Jul 31, 2012 8:47 am
Location: Aberdeen, Scotland
Contact: Website

Re: Bare Metal ZX81 emulator

Sun Nov 18, 2012 9:04 pm

:|

gertk
Posts: 52
Joined: Mon Aug 29, 2011 9:08 am

Re: Bare Metal ZX81 emulator

Sun Nov 18, 2012 9:05 pm

Got a link from Alex to the source of libcsud so I can investigate.

Return to “Bare metal, Assembly language”