jubber
Vector Runner
Posts: 12
|
Post by jubber on Jun 8, 2018 23:13:07 GMT -5
Hi there chaps - a new question. I've found somebody who supplies vectrex pcbs for my upcoming game, which can take 64K or 32K prom/eproms. Considering that 64K and 32K proms are both just over a quid I figure making my game use 64K makes more sense - especially as I'm getting very close to my original 32K limit. I can always add more content and it would be nice not to have to chase down every single spare byte.
However, now that I've ordered some 64K chips, I have no idea how using the extra 32K of rom is actually achieved. An 8 bit cpu can, I assume, only access a 64K address space - but that has to include ram, rom and bios. So... bank switching must be a thing.
How is this achieved from software? Can it be done via software or is a 64K chip a bit useless?
Cheers for any illumination.
Robin.
|
|
jubber
Vector Runner
Posts: 12
|
Post by jubber on Jun 9, 2018 15:57:43 GMT -5
Somebody on a different forum mentioned the following code
;************************************************************************************************************************************************************************************************** Bank_Switch_2_Bank_0: ldb HW_Bportd ; make the PB6-line of the VIA an output.. orb #%01000000 stb HW_Bportd jmp Main_Init
;************************************************************************************************************************************************************************************************** Bank_Switch_2_Bank_1: ldb HW_Bportd ; make the PB6-line of the VIA an input > jumping to address 8000..FFFF of the eprom andb #%10111111 stb HW_Bportd jmp Main_Init ; go to start
;**************************************************************************************************************************************************************************************************
which implies I need a copy of the initial header and main loop - but with new names. How do I get the compiler to add this code in at 8000? org 8000 isn't accepted, so it's not that.
Unless... make two binary files, pad the first one out and physically stick the new one on at the end? hmmm
|
|
|
Post by Malban on Jun 9, 2018 19:40:13 GMT -5
Mostly taken from Vide documentation:
...
The "classic" bankswitching (as first done by John Dondzila) uses the cartridge line 35, which is directly connected to the VIA. More exactly to VIA port B bit 6 (hence PB6 line).
The state of PB6 is "calculated" quite easy as:
- if pb6 is in input mode (corresponding bit 6 of ddrb is 0) -> than pb6 is always 1 (well - if someone on the cartridge side "writes a 0" than not - but usually the cartridges do NOT write to pb6)
- if pb6 is in output mode - pb6 is always that which is written to pb6
Knowing the above and also knowing that the BIOS never writes anything other than "0" (zero) zo PB6 - bankswitching is done very easily by just switching pb6 from input mode to output mode or vice versa to change the state of the line (and thus do bankswitching). (also remember - the BIOS quite often writes to port B, so if you do NOT use the input/output method, you better make sure, that bit 6 is always correct!)
--- For completeness sake - small "warning" ---
VIA is "clever" enough to remember the last value that was set to PB6. So if you set PB6 to 0, switch to bank one (by switching to input mode) PB6 READS 1 (but still remembers 0 as last WRITTEN value). If you switch back to bank 0 (by switching to output mode), PB6 will READ 0 (zero) again - clever.
However, there can be a "trap":
clr <VIA port b inc <VIA port b
That instruction sequence is not really uncommon. The first line enables the mux and sets the mux to y-integrators. The second line disables the mux (and usually after that you set a value to portA and than have set xy coordinates of some sort).
The thing is - if you do above sequence while in bank 0 (pb6 = 0) the value in port B is (binary): % 0000 0001 - pretty much what you suspect.
If you do the same sequence while in bank 1 (pb6 in input mode - always reads 1) the value in port B is (binary): % 0100 0001
The "inc" instruction does a READ from pb6. And that read is always 1. The inc instruction internally READS the value, increases the value by one and WRITES the value back. And thus VIA does not remember the last zero we set anymore - since the last value that was set was a ONE (by the inc instruction).
If you try to switch back to bank 0 using the above input/output method you will NOT switch, since PB6 is not set to zero anymore.
Malban
PS Vide can assemble 64kb bankswitched binaries. If you use another assembler you most probably must do what you suggested - pad and concatinate the two binaries. You probably will do a script for that :-).
Also note - the default (start) bank is bank 1 not bank 0!
|
|
jubber
Vector Runner
Posts: 12
|
Post by jubber on Jun 9, 2018 20:37:38 GMT -5
Thanks Malban - some handy information there. After some swearing I've managed to get the pad and concatenate approach working. I promise I'll use VIDE for my next game :-)
Cheers,
Robin.
|
|