Videopac / Odyssey2 forum
December 14, 2019, 11:05:28 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: If you have some news and you want it to be shown here, pm Janzl!
 
   Home   arcade Help Login Register links videopac.nl  
Pages: [1]   Go Down
  Print  
Author Topic: figuring out how to put two 2k games together into one 4k cart  (Read 7197 times)
Chris!
Give this man a Jopac!
******
Posts: 1148



WWW
« on: September 09, 2014, 09:40:05 AM »

After an hour or so of fiddling around, I figured out how to put two 2k games into one 4k cart. Here's what you need to put at the beginning of the program.
Code:
cpu 8048

org 400h

include "g7000.h"

jmp 02c3h
jmp irq ; interrupt
jmp timer ; timer
jmp vsyncirq ; VSYNC-interrupt
jmp start ; after selectgame
jmp soundirq ; sound-interrupt

timer
;retr




start
mov r7,a
xrl a,#002h ; adjust x pos
jz jumptogame_2

jmp begin_game_1


jumptogame_2
jmp 0387h

begin_game_1
In this example, if the number 2 is pressed the game will go to the second game in the other bank. All other button presses lead to the first game. Ah, the thrill of discovery.
Logged

All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html
Ozyr
Totally devoted to Videopac
*******
Posts: 1508


Packrat Video Games


david.flemming.9
WWW
« Reply #1 on: September 09, 2014, 12:28:11 PM »

Interesting. Would be curious if this is how other games did this too (not that what you found is wrong - cool stuff)?
Logged

manopac
Game & App Development
Give this man a Jopac!
*
Posts: 1123



« Reply #2 on: September 09, 2014, 03:48:31 PM »

yes, this is how most games do it - because it's the standard "Select Game" routine anyways ...
also, it is described in the g7kbios document by Sören Gust ...

"At power on or after reset the BIOS jumps directly to 0400h, the first address of the external ROM. Normally
you put a  jmp selectgame = 02C3h there, this initialises the VDC, internal and external RAM. Then it
displays the "SELECT GAME" message and waits for a key. After that it jumps to 0408h. There you have to
start your code with another jmp, because 040Ah is used by the interrupt. Which key was pressed is stored in A.
All sprites, chars, quads and the grids are initialised, the VDC is enabled and the graphics are on."

the essential parts of the source above (the one actually taking care of the selection, minus all the BIOS and Interrupt-Vectors you have to put on the lines described by the BIOS, details can be read in the doc mentioned above)

   jmp 02c3h                                    <- (because BIOS on address 0000h jumps to address 0400h, so this is the very start of every program on an ody2 or G7000) make a jump to the Select game routine (better would be "jmp BIOS_selectgame", as this would also work with g7000.h included and makes the code readable)

   jmp   start      ; after selectgame    <- the select game BIOS routine jumps to the address stored in 0408h after the user presses a key


start
   mov r7,a                                          <- select game returns the pressed key in the accumulator, here it is saved in r7, you only need this if you want to compare to more than one key and thus need the result of selectgame again
   xrl a,#002h   ; adjust x pos                   <- doing an xor creates essentially a comparison -> if the result is zero, then a = 02h
   jz jumptogame_2                                <- so jump to game 2 if the result is zero ... (= Key 2)

   jmp begin_game_1                             <- otherwise jump to game 1

jumptogame_2
   jmp 0387h                                        <- jump to game 2 (in Bank0 -> this is equivalent to "jmp BIOS_bank0"

begin_game_1

but all this is, is a comparison which key the select game routine returns (and jumping accordingly) - the switch and jumps can differ if for example no bank switching is involved (e.g., the first 2K games with two ore more games) - then no bankswitching, but jumps to addresses in the same bank would be used ...

« Last Edit: September 09, 2014, 04:29:10 PM by manopac » Logged

sex, lies, and videopac
manopac
Game & App Development
Give this man a Jopac!
*
Posts: 1123



« Reply #3 on: September 09, 2014, 03:54:32 PM »

and just for the fun of it - here's what you would do if you need 3 keys and want the user to only switch with 1, 2 and 3, and no other key:

start:
   mov r7,a
   xrl a,#001h   
   jnz noGame1

   jmp begin_game_1

noGame1
   mov a,r7
   xrl a,#002h   
   jnz noGame2

   jmp begin_game_2

noGame2
   mov a,r7
   xrl a,#003h   
   jnz noGameSelected

   jmp begin_game_3

noGameSelected
       jmp BIOS_selectgame
Logged

sex, lies, and videopac
Chris!
Give this man a Jopac!
******
Posts: 1148



WWW
« Reply #4 on: September 09, 2014, 07:07:54 PM »

Soren Gust's website is no more, and I'm having a bit of a problem with that.
Logged

All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html
Janzl
Administrator
I'd sell my mother for a Videopac
*****
Posts: 2331


I now can cross that bloody street...


facebook@janzl.com
WWW
« Reply #5 on: September 10, 2014, 12:26:05 AM »

I'm happy I downloaded his docs long ago Smiley Not that I ever use them anymore Sad
Logged

Ne tirez pas sur le administrator!
Ozyr
Totally devoted to Videopac
*******
Posts: 1508


Packrat Video Games


david.flemming.9
WWW
« Reply #6 on: September 10, 2014, 06:54:11 AM »

Soren Gust's website is no more, and I'm having a bit of a problem with that.

What? I was on his site not that long ago. Would be curious as to what happened. Plus would be nice to move that programming stuff to another location if possible, as I'm sure some would still find it useful.
Logged

manopac
Game & App Development
Give this man a Jopac!
*
Posts: 1123



« Reply #7 on: September 10, 2014, 08:15:30 AM »

Soren Gust's website is no more, and I'm having a bit of a problem with that.

damn ... you are right ... if you want the tech doc from his site, drop me a PM with your email and I'll send it to you
Logged

sex, lies, and videopac
timdu
Freedom Fighter
****
Posts: 304



« Reply #8 on: September 10, 2014, 08:21:05 AM »

A few months ago, I asked Rene some questions about learning assembly, and he informed me that:

Soeren Gusts website was a great start to learn Videopac assembly, but it doesn't seem to exist anymore. However, you can find it in the internet archives here:

http://web.archive.org/web/20130608030041/http://soeren.informationstheater.de/g7000/toc.html


Tim
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!