Jump to content

Photo

Games over 4K


29 replies to this topic

#1 BNE Jeff OFFLINE  

BNE Jeff

    Moonsweeper

  • 367 posts
  • Location:$5787

Posted Sat Dec 30, 2017 4:25 AM

Good Morning,

 

What's the best (and/or easiest) way to make games larger than 4K?

 

Thanks!



#2 nanochess OFFLINE  

nanochess

    Processorus Polyglotus

  • 5,797 posts
  • Coding something good
  • Location:Mexico City

Posted Sat Dec 30, 2017 9:39 AM

Hi.

The easiest way is to use the standard F8 method.

At top of ROM put same reset address in both 4k banks and select one of the banks doing LDA $FFF8 (bank 0) or LDA $FFF9 (bank 1)

The whole 4K bank is replaced and next instruction will be read from the selected bank.

#3 JeremiahK OFFLINE  

JeremiahK

    Chopper Commander

  • 223 posts
  • Location:Indiana, USA

Posted Sat Dec 30, 2017 10:18 AM

Usually you would do this by having a group of labels either at the beginning or end of each bank, one for each address in other banks that you want to be able to jump to from that bank. To switch banks, you jump to the label you want, which selects the bank, and then after it is switched, jumps to the actual address you want to get to. You have to make sure the bank switching instructions line up with the following instructions on the next bank, because the program counter doesn't change when the bank switches, it marches on from wherever it was.

#4 JeremiahK OFFLINE  

JeremiahK

    Chopper Commander

  • 223 posts
  • Location:Indiana, USA

Posted Sat Dec 30, 2017 10:32 AM

Another option, if you can use a couple bytes of temp RAM, is to use an indirect jump. Load the desired final address into a pointer, and jump to the label that switches to the desired bank. From there do an indirect jump to the pointer.

#5 BNE Jeff OFFLINE  

BNE Jeff

    Moonsweeper

  • Topic Starter
  • 367 posts
  • Location:$5787

Posted Sat Dec 30, 2017 10:35 AM

Thanks..  Doesn't sound too bad..  Is it limited to 2- 4K banks?



#6 JeremiahK OFFLINE  

JeremiahK

    Chopper Commander

  • 223 posts
  • Location:Indiana, USA

Posted Sat Dec 30, 2017 10:51 AM

For F8 bankswitching, yes there are only 2 banks, but you can have more banks with other methods.  Here is a list of bankswitching methods and how they work: https://www.scribd.c...itching-methods



#7 BNE Jeff OFFLINE  

BNE Jeff

    Moonsweeper

  • Topic Starter
  • 367 posts
  • Location:$5787

Posted Sat Dec 30, 2017 11:00 AM

Thanks again!  So F6 looks pretty much the same as F8, but for 4- 4K banks.  I think that one looks good.  To your earlier post- I'm writing up a routine right now that uses a lot of indirect jumps so that would work nicely here..


Edited by BNE Jeff, Sat Dec 30, 2017 11:00 AM.


#8 SpiceWare OFFLINE  

SpiceWare

    Draconian

  • 12,629 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Sat Dec 30, 2017 11:08 AM

The way I did it in Medieval Mayhem seemed like a logical way to do it.  I used macros JUMP_TABLE and BANKS_AND_VECTORS at the start and end of every bank.  MM's a 32K game so there's 8 banks, the same technique will work work fewer banks.
 
        MAC JUMP_TABLE ; put this at the start of every bank
        RORG $F000
InitSystem
        cmp SelectBank5   ; inits system then goes to the menu
        jmp InitSystemCode
VerticalBlankMenu
        cmp SelectBank8
        jmp VerticalBlankMenuCode
KernelMenu
	cmp SelectBank6
	jmp KernelMenuCode
VerticalBlankGame
        cmp SelectBank1
        jmp VerticalBlankGameCode
KernelGame
        cmp SelectBank8    ; draws score, top castles, dragons
        jmp KernelGameCode
KernelGameDragon
        cmp SelectBank2    ; draws bottom castles
        jmp KernelGameDragonCode
KernelGameDragon2
        cmp SelectBank3    ; draws bottom castles
        jmp KernelGameDragon2Code
KernelGameBottom
        cmp SelectBank5    ; draws bottom castles
        jmp KernelGameBottomCode
OverscanMenu2             ; Menu Entry Point if user hits SELECT
        cmp SelectBank6   ; or RESET during a game
        jmp OverscanMenu2Code
OverscanGame
        cmp SelectBank7
        jmp OverscanGameCode
OverscanGame2
        cmp SelectBank2
        jmp OverscanGame2Code
StartRound
        cmp SelectBank8
        jmp StartRoundCode
        ENDM

        MAC BANKS_AND_VECTORS ; put this at the end of every bank
        RORG $FFF4
SelectBank1 .byte $00
SelectBank2 .byte $00
SelectBank3 .byte $00
SelectBank4 .byte $00
SelectBank5 .byte $00
SelectBank6 .byte $00
SelectBank7 .byte $00
SelectBank8 .byte $00
;       .word InitSystem ; 7 and 8 overlap NMI
        .word InitSystem ; RESET
        .word InitSystem ; IRQ
        ENDM
 
 
You can find the source in the Medieval Mayhem blog entries.

#9 BNE Jeff OFFLINE  

BNE Jeff

    Moonsweeper

  • Topic Starter
  • 367 posts
  • Location:$5787

Posted Sat Dec 30, 2017 12:08 PM

Neat..

 

Trying to grasp it..

 

The CMPs cause  the processor to read from an address at $FFF4 through $FFFC. Value of zero in those locations is irrelevant.

The access causes the bank switch somehow.

The following jump statement is executed in the new bank or does it execute when it returns?



#10 BNE Jeff OFFLINE  

BNE Jeff

    Moonsweeper

  • Topic Starter
  • 367 posts
  • Location:$5787

Posted Sat Dec 30, 2017 12:11 PM

Its executed in the new bank isn't it, because the identical code is there too- right?



#11 SpiceWare OFFLINE  

SpiceWare

    Draconian

  • 12,629 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Sat Dec 30, 2017 1:31 PM

Yep, as soon as $FFF4 thru $FFFC are accessed the bank is switched.

I do recommend changing those to NOP instead of CMP as the CMP will set various flags which can cause unintended results to occur in your code. I wasn't aware of the illegal opcode variations of NOP at the time.

#12 BNE Jeff OFFLINE  

BNE Jeff

    Moonsweeper

  • Topic Starter
  • 367 posts
  • Location:$5787

Posted Sun Dec 31, 2017 7:44 AM

Alright..

 

I managed to turn my "framework" code into a 32k bin with the help of the Medieval Mayhem blog.  I put all of it in bank 5.  Its not working yet though.  It looks like its running through the reset routine, then pointing to a RAM address then resetting again.  These labels look wrong too, Its adding "Game" to some of them, "InitSystem" Isn't my label for that routine, and labels are missing for SelectBank1 and SelectBank2 in MAC BANKS_AND_VECTORS.  Also, my VerticalSync routine isn't there.

SS 123117-2.jpg

SS 123117.jpg

Attached Files


Edited by BNE Jeff, Sun Dec 31, 2017 7:48 AM.


#13 Omegamatrix OFFLINE  

Omegamatrix

    Quadrunner

  • 6,227 posts
  • Location:Canada

Posted Sun Dec 31, 2017 6:32 PM

Alright..

 

I managed to turn my "framework" code into a 32k bin with the help of the Medieval Mayhem blog.  I put all of it in bank 5.  Its not working yet though.  It looks like its running through the reset routine, then pointing to a RAM address then resetting again.  These labels look wrong too, Its adding "Game" to some of them, "InitSystem" Isn't my label for that routine, and labels are missing for SelectBank1 and SelectBank2 in MAC BANKS_AND_VECTORS.  Also, my VerticalSync routine isn't there.

The code didn't compile correctly. You need to use ORG to define where the code goes in the physical rom, an RORG to give it a valid ROM space address.

 

Valid rom space for a 2600 game is:

$1xxx

$3xxx

$5xxx

$7xxx

$9xxx

$Bxxx

$Dxxx

$Fxxx

 

You can do someting like this:

ORG $C000

RORG $F000

 

You can RORG to addresses you have used before.



#14 BNE Jeff OFFLINE  

BNE Jeff

    Moonsweeper

  • Topic Starter
  • 367 posts
  • Location:$5787

Posted Mon Jan 1, 2018 3:48 AM

Ahh...  Thank you..

 

Yeah RORG is new to me.. I think I have a basic idea of what its doing now..  In this case the macro JUMP_TABLE contains the RORG and I just had the macro in the wrong place:
SS 010118.jpg

So, I moved it up under ORG $C000 and now the code is working..

 

Thanks Again!



#15 BNE Jeff OFFLINE  

BNE Jeff

    Moonsweeper

  • Topic Starter
  • 367 posts
  • Location:$5787

Posted Sat Feb 3, 2018 7:50 AM

So I'm curious how this works..  Is there a little bit of extra hardware in the cartridge that "listens" in on those addresses and then directs the bus to a bank?  Perhaps a simple set of transistors turned high by the read? (I'm not an electronics whiz)



#16 CurtisP OFFLINE  

CurtisP

    Moonsweeper

  • 260 posts

Posted Sat Feb 3, 2018 9:23 PM

So I'm curious how this works..  Is there a little bit of extra hardware in the cartridge that "listens" in on those addresses and then directs the bus to a bank?  Perhaps a simple set of transistors turned high by the read? (I'm not an electronics whiz)

 

There is extra hardware in the cart. A flip flop and some NAND gates to drive it. See this thread http://atariage.com/...nkswitching-f8/

 

Edit: This is how it would have been done back in the day. See below for how it's done now.


Edited by CurtisP, Sun Feb 4, 2018 1:25 PM.


#17 Albert OFFLINE  

Albert

    Quadrunner

  • 35,189 posts

Posted Sat Feb 3, 2018 9:44 PM

There is extra hardware in the cart. A flip flop and some NAND gates to drive it. See this thread http://atariage.com/...nkswitching-f8/

 

Or a PLD (Programmable Logic Device), such as a 22V10, that contains the bankswitching logic and can be programmed to support a variety of bankswitching methods. 

 

 ..Al



#18 CurtisP OFFLINE  

CurtisP

    Moonsweeper

  • 260 posts

Posted Sun Feb 4, 2018 1:23 PM

 

Or a PLD (Programmable Logic Device), such as a 22V10, that contains the bankswitching logic and can be programmed to support a variety of bankswitching methods. 

 

 ..Al

In other words, flash a Melody board and call it a day? 


Edited by CurtisP, Sun Feb 4, 2018 1:24 PM.


#19 Albert OFFLINE  

Albert

    Quadrunner

  • 35,189 posts

Posted Sun Feb 4, 2018 6:38 PM

In other words, flash a Melody board and call it a day? 

 

Well, that's taking it to an entire new level, given the Melody board has an onboard ARM processor.  That's generally what I use, though, when testing games on real hardware during development. 

 

 ..Al



#20 BNE Jeff OFFLINE  

BNE Jeff

    Moonsweeper

  • Topic Starter
  • 367 posts
  • Location:$5787

Posted Sun Dec 9, 2018 2:54 PM

The way I did it in Medieval Mayhem seemed like a logical way to do it.  I used macros JUMP_TABLE and BANKS_AND_VECTORS at the start and end of every bank.  MM's a 32K game so there's 8 banks, the same technique will work work fewer banks.
 


        MAC JUMP_TABLE ; put this at the start of every bank
        RORG $F000
InitSystem
        cmp SelectBank5   ; inits system then goes to the menu
        jmp InitSystemCode
VerticalBlankMenu
        cmp SelectBank8
        jmp VerticalBlankMenuCode
KernelMenu
	cmp SelectBank6
	jmp KernelMenuCode
VerticalBlankGame
        cmp SelectBank1
        jmp VerticalBlankGameCode
KernelGame
        cmp SelectBank8    ; draws score, top castles, dragons
        jmp KernelGameCode
KernelGameDragon
        cmp SelectBank2    ; draws bottom castles
        jmp KernelGameDragonCode
KernelGameDragon2
        cmp SelectBank3    ; draws bottom castles
        jmp KernelGameDragon2Code
KernelGameBottom
        cmp SelectBank5    ; draws bottom castles
        jmp KernelGameBottomCode
OverscanMenu2             ; Menu Entry Point if user hits SELECT
        cmp SelectBank6   ; or RESET during a game
        jmp OverscanMenu2Code
OverscanGame
        cmp SelectBank7
        jmp OverscanGameCode
OverscanGame2
        cmp SelectBank2
        jmp OverscanGame2Code
StartRound
        cmp SelectBank8
        jmp StartRoundCode
        ENDM

        MAC BANKS_AND_VECTORS ; put this at the end of every bank
        RORG $FFF4
SelectBank1 .byte $00
SelectBank2 .byte $00
SelectBank3 .byte $00
SelectBank4 .byte $00
SelectBank5 .byte $00
SelectBank6 .byte $00
SelectBank7 .byte $00
SelectBank8 .byte $00
;       .word InitSystem ; 7 and 8 overlap NMI
        .word InitSystem ; RESET
        .word InitSystem ; IRQ
        ENDM
 
 
You can find the source in the Medieval Mayhem blog entries.

 

 

Can this same method be used to make 64 K game?



#21 Thomas Jentzsch OFFLINE  

Thomas Jentzsch

    Thrust, Jammed, SWOOPS!, Boulder Dash, THREE·S, Star Castle

  • 23,941 posts
  • Always left from right here!
  • Location:Düsseldorf, Germany, Europe, Earth

Posted Mon Dec 10, 2018 2:59 AM

Sure. But the more banks you have, the more likely your code accesses multiple banks and the longer and more complicated to maintain the bankswitching list becomes.

 

So something less straightforward and bit more sophisticated (and slower) seems more appropriate. E.g.

  bit SelectBank1,y ; y = bank number
  jmp (vector)      ; vector setup by calling code e.g via macro

Therefore I have created certain bankswitching macros on my own, which even make bankswitching transparent, so they are quite convenient to use.  I can post them here when I am back at home.


Edited by Thomas Jentzsch, Mon Dec 10, 2018 3:00 AM.


#22 SpiceWare OFFLINE  

SpiceWare

    Draconian

  • 12,629 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Mon Dec 10, 2018 9:21 AM

Depends upon the bankswitch scheme.  I've not kept up with board developments, just checked and see UnoCart supports 3F, EF and F0 for 64K. I checked Stella's source to see how they work:

 

3F - Has thirty-two 2K banks. The first 2K of cartridge space ($F000-F7FF) get swapped, last 2K is always mapped to the last 2K bank.  Bankswitch is done by writing the desired bank to address $3F.

 

EF - has sixteen 4K banks.  Uses $1FE0 - $1FEF to select bank, so would need to adjust the BANKS_AND_VECTORS.

 

F0 - has sixteen 4K banks.  Accessing $1FF0 switches to next bank, so you don't get to arbitrarily select a bank.

 

 

So of those EF could be made to work with my example.  As Thomas mentions, if you do it this way the overhead increases (as more of each 4K bank is dedicated to bank switching code) so finding a better way to do it would be in your best interesting.  

 

One side affect of my switching to ARM support for my games is they only use 1 bank of 6507 code, and the ARM sees everything without needing to bankswitch, so I've not looked into better ways to do it.



#23 Thomas Jentzsch OFFLINE  

Thomas Jentzsch

    Thrust, Jammed, SWOOPS!, Boulder Dash, THREE·S, Star Castle

  • 23,941 posts
  • Always left from right here!
  • Location:Düsseldorf, Germany, Europe, Earth

Posted Mon Dec 10, 2018 9:30 AM

Maybe I should post something like my "SaveKey for Dummies" thread. :)



#24 Dionoid OFFLINE  

Dionoid

    Chopper Commander

  • 127 posts
  • Location:Leiden, Netherlands

Posted Mon Dec 10, 2018 10:41 AM

Maybe I should post something like my "SaveKey for Dummies" thread. :)


Yes, please! :-)

#25 Thomas Jentzsch OFFLINE  

Thomas Jentzsch

    Thrust, Jammed, SWOOPS!, Boulder Dash, THREE·S, Star Castle

  • 23,941 posts
  • Always left from right here!
  • Location:Düsseldorf, Germany, Europe, Earth

Posted Tue Dec 11, 2018 11:27 AM

Done! :)






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users