New Game - wip
Moderator: Moderators
New Game - wip
Hello all,
I have finally started to work on a game for the unexpanded Vic, I don't have the real machine, I hope Vice emulation is sufficiently mature to allow me to go through and finish this project.
I have been looking in a away to install an interrupt, but it seems I can't have it without the Kernal running? is this correct? I see that the vectors are in $314-$315 only? I need a counter in my game - a clock, I was thinking of using an interrupt but as I don't want to use the kernal to have all the ZP free I think I must use a timer?!. Can someone tell me how to implement a timer and use it to run a clock? Thank you.
Memory Map
----------
$0200-$02ff panel matrix
$0300-$03ff level matrix
$1001-$100c Boot
$100d-$128a main program
$1800-$1aff Screen Ram
$1c00-$1c87 chars UDG
$1c88-$1ca7 Level 1 //just to test
$9400-$96ff Ram color
I am using the chars from rom and 16 udg chars for the box at the bottom where the picture the player is working on will be sowed up.
As the memory is tight I don't know yet how many levels I will be able to cram in.
Here you can see the screen, it is not finished, I need to add the score, Time and hiscore, and also the rest of the guide lines and columns(those with numbers). The purple color is not definitive I just filled the screen with it when I was testing the ram color.
I have finally started to work on a game for the unexpanded Vic, I don't have the real machine, I hope Vice emulation is sufficiently mature to allow me to go through and finish this project.
I have been looking in a away to install an interrupt, but it seems I can't have it without the Kernal running? is this correct? I see that the vectors are in $314-$315 only? I need a counter in my game - a clock, I was thinking of using an interrupt but as I don't want to use the kernal to have all the ZP free I think I must use a timer?!. Can someone tell me how to implement a timer and use it to run a clock? Thank you.
Memory Map
----------
$0200-$02ff panel matrix
$0300-$03ff level matrix
$1001-$100c Boot
$100d-$128a main program
$1800-$1aff Screen Ram
$1c00-$1c87 chars UDG
$1c88-$1ca7 Level 1 //just to test
$9400-$96ff Ram color
I am using the chars from rom and 16 udg chars for the box at the bottom where the picture the player is working on will be sowed up.
As the memory is tight I don't know yet how many levels I will be able to cram in.
Here you can see the screen, it is not finished, I need to add the score, Time and hiscore, and also the rest of the guide lines and columns(those with numbers). The purple color is not definitive I just filled the screen with it when I was testing the ram color.
Re: New Game - wip
The Kernal is always running in the VIC since it can't be banked out as on the C64. On the other hand, if you dont use any Kernal or BASIC routines you're free to use most of zp anyway.Progra wrote:I have been looking in a away to install an interrupt, but it seems I can't have it without the Kernal running?
Bacon
-------------------------------------------------------
Das rubbernecken Sichtseeren keepen das cotton-pickenen Hands in die Pockets muss; relaxen und watschen die Blinkenlichten.
-------------------------------------------------------
Das rubbernecken Sichtseeren keepen das cotton-pickenen Hands in die Pockets muss; relaxen und watschen die Blinkenlichten.
Re: New Game - wip
What I did was to use SEI and then don't CLIBacon wrote:The Kernal is always running in the VIC since it can't be banked out as on the C64. On the other hand, if you dont use any Kernal or BASIC routines you're free to use most of zp anyway.Progra wrote:I have been looking in a away to install an interrupt, but it seems I can't have it without the Kernal running?
- Mike
- Herr VC
- Posts: 4846
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: New Game - wip
As Bacon already said, on the VIC the KERNAL is always mapped in, so IRQ's are forcibly vectored through ($0314). But these aren't the only relevant vectors. BRK instructions, and NMI's are vectored through ($0316) and ($0318).Progra wrote:I have been looking in a away to install an interrupt, but it seems I can't have it without the Kernal running? is this correct? I see that the vectors are in $314-$315 only?
Here an example of an interrupt driven clock, displayed in the border. It shouldn't be too difficult to adapt it to your own needs.I need a counter in my game - a clock, [...]
There's a 60 Hz IRQ provided by the KERNAL, to read the keyboard, check the STOP key, and update the system clock in $A0, $A1, and $A2. The clock display simply wedges into that interrupt.
Since your map shows a gap in usage between $128B to $17FF, why do you feel you need to use the lower 1K? I'd rather stick to $1000 .. $1FFF for code, and data at the moment. There are enough ZP addresses ($FB .. $FE, and all those shared between tape, and RS232 operations) which can be used without problems by your own program. Some small areas in the lower 1K, $02A1 .. $02FF, and $033C .. $03FF (the last being the tape buffer) are essentially free, as well.[...]I was thinking of using an interrupt but as I don't want to use the kernal to have all the ZP free I think I must use a timer?!. Can someone tell me how to implement a timer and use it to run a clock?
Memory Map
----------
$0200-$02ff panel matrix
$0300-$03ff level matrix
But then, IRQ's won't work anymore. And NMI's are still vectored through ($0318).What I did was to use SEI and then don't CLI.
Greetings,
Michael
Thank you Mike,
I will study what you have said. I have the clock code already as I coded it for my C64 picross game, it is IRQ driven. I was asking because I was thinking of not using IRQ as I wanted ZP free and I have never used timers before.
The new mem map:
Memory Map
----------
*$0200-$02ff matrix painel
*$0300-$03ff matrix nivel
$1001-$100c Boot
$100d-$140c programa principal
*$1800-$1aff Screen Ram
$1c00-$1c87 chars UDG
$1c88-$1ca7 Unnamed
*$9400-$96ff Ram color
I must see now how the joystick is read on the vic20...
New pic
I will study what you have said. I have the clock code already as I coded it for my C64 picross game, it is IRQ driven. I was asking because I was thinking of not using IRQ as I wanted ZP free and I have never used timers before.
The new mem map:
Memory Map
----------
*$0200-$02ff matrix painel
*$0300-$03ff matrix nivel
$1001-$100c Boot
$100d-$140c programa principal
*$1800-$1aff Screen Ram
$1c00-$1c87 chars UDG
$1c88-$1ca7 Unnamed
*$9400-$96ff Ram color
I must see now how the joystick is read on the vic20...
New pic
- Mike
- Herr VC
- Posts: 4846
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Without IRQ's, you'd need to time out your code for execution time, and then poll the clock update. This is rather inconvenient, and depends upon (at least near) the same execution time for your game main loop.Progra wrote:I will study what you have said. I have the clock code already as I coded it for my C64 picross game, it is IRQ driven. I was asking because I was thinking of not using IRQ [...]
In another thread, I discussed together with rhurst a simple way to create a 'raster' IRQ using the timers of the VIA chips. This might give you some ideas.[...]I have never used timers before.
Why do you want to have a free zeropage? IMO the only unavoidable reason to use a (pair of) ZP address(es) is as pointer with post-indexed indirect addressing, like 'LDA ($FB),Y'. Practically everything else can be done outside the ZP.[...] [and] as I wanted ZP free [...]
There's a small snippet of code in the Denial Wiki, at the bottom of the page: http://sleepingelephant.com/denial/wiki ... e=JoystickI must see now how the joystick is read on the vic20 ...
Greetings,
Michael
You will probably understand how it is from Mike's link. But if you want further information, there is a good section in the VIC-20 Programmers Reference Guide that covers reading the joystick in more depth. You can find a txt version of the book on zimmers: http://zimmers.net/anonftp/pub/cbm/vic2 ... 1.1.txt.gz. It starts on page 246.Progra wrote: I must see now how the joystick is read on the vic20...
Thank you Mike,
I didn't realize it was that complicated to use the timers, I mean knowing the execution time of my code etc. I think I must go with the IRQ. The problem is that I need to have those two tables 256 bytes each and they can't seat where they are (ie $200 -> $3FF) if I use the Interrupt. But I see anyway that I had to take care of the NMI vector and that was being part of one of the tables...
Actually I haven't been using the zp indexing, I am using self modifying code. But I have used from vars I store there but as you say I can relocate them to other places.
Instead of spending 256 bytes on each table I could check the bits and save mem but then the code to handle that perhaps wouldn't justify doing like that.
hmm...
Memory Map
----------
$1001-$100c Boot
$100d-$140a main code
*$1800-$1aff Screen Ram
*$1b00-$1bff matrix panel
$1c00-$1c87 chars UDG
$1d00-$1d1f Levels
*$1f00-$1fff matrix level
*$9400-$96ff Ram color
Thank you Wilson. I will check the VIC-20 PRGuide.
I didn't realize it was that complicated to use the timers, I mean knowing the execution time of my code etc. I think I must go with the IRQ. The problem is that I need to have those two tables 256 bytes each and they can't seat where they are (ie $200 -> $3FF) if I use the Interrupt. But I see anyway that I had to take care of the NMI vector and that was being part of one of the tables...
Actually I haven't been using the zp indexing, I am using self modifying code. But I have used from vars I store there but as you say I can relocate them to other places.
Instead of spending 256 bytes on each table I could check the bits and save mem but then the code to handle that perhaps wouldn't justify doing like that.
hmm...
Memory Map
----------
$1001-$100c Boot
$100d-$140a main code
*$1800-$1aff Screen Ram
*$1b00-$1bff matrix panel
$1c00-$1c87 chars UDG
$1d00-$1d1f Levels
*$1f00-$1fff matrix level
*$9400-$96ff Ram color
Thank you Wilson. I will check the VIC-20 PRGuide.
- Mike
- Herr VC
- Posts: 4846
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
I think we've crossed the wires somehow.Progra wrote:I didn't realize it was that complicated to use the timers, I mean knowing the execution time of my code etc.
It isn't really difficult to use the timers. You just have to know how to program the registers in the right sequence.
Timing out your program would only be necessary, if you *don't* use any interrupt, or external counters like the raster counter, to implement a clock. The clock's accuracy depends upon the update routine called regularily, and you'd need to devise a game main loop with near constant execution time, polling the clock update.
This is far easier to program using interrupts.
If you use an external clock source like the raster counter, you will run into problems when there's an interrupt present with nearly the same rate. This had been discussed in the aforementioned thread, where the first design checked for a certain raster line before continuing execution. On NTSC machines, the keyboard IRQ (also with 60 Hz) can hinder the test, dropping not only one frame, but several frames in a row.
The IRQ routine presented there simply takes that to advantage, using a synchronised IRQ to indicate a raster line has passed, and checking for a flag in the game main loop.
As you want to use a bigger screen, you might consider putting it at $1C00. The 17 UDG's you're using could be copied to $1F78 .. $1FFF (chars 111 .. 127), and the remainder from the end of screen data up to $1F77 can be used for variable data. This way, you keep the program between $1000 .. $1BFF in one piece.Memory Map
----------
$1001-$100c Boot
$100d-$140a main code
*$1800-$1aff Screen Ram
*$1b00-$1bff matrix panel
$1c00-$1c87 chars UDG
$1d00-$1d1f Levels
*$1f00-$1fff matrix level
*$9400-$96ff Ram color
Last edited by Mike on Sun Nov 01, 2009 3:38 pm, edited 1 time in total.
Thx Mike, I will try to move the mem about and have a continuous block for the game code.
I have now the program running using the interrupts, and the clock is working.
The worse bit now is to make the rest fit the tiny amount of memory. I want to have a fair number of levels. I think I will need to go back into the code and optimize it somehow if things get tight.
Memory Map
----------
$1001-$100c Boot
$100d-$15d7 main code
*$1800-$1aff Screen Ram
*$1b00-$1bff matrix panel
$1c00-$1c87 chars UDG
$1d00-$1d1f Levels
*$1f00-$1fff matrix level
*$9400-$96ff Ram color
I still need to code :
* the Joystick part(includes movement of a target over the panel, etc.)
* the handling of the score and hiscore
* title screen
I have now the program running using the interrupts, and the clock is working.
The worse bit now is to make the rest fit the tiny amount of memory. I want to have a fair number of levels. I think I will need to go back into the code and optimize it somehow if things get tight.
Memory Map
----------
$1001-$100c Boot
$100d-$15d7 main code
*$1800-$1aff Screen Ram
*$1b00-$1bff matrix panel
$1c00-$1c87 chars UDG
$1d00-$1d1f Levels
*$1f00-$1fff matrix level
*$9400-$96ff Ram color
I still need to code :
* the Joystick part(includes movement of a target over the panel, etc.)
* the handling of the score and hiscore
* title screen
I had no time yesterday to do more...
Here is a screen-shot of the c64 picross game I am working on, it is more advanced than the vic's version.
There is a short video of it too: http://www.youtube.com/watch?v=5tqbgIOKa10
Here is a screen-shot of the c64 picross game I am working on, it is more advanced than the vic's version.
There is a short video of it too: http://www.youtube.com/watch?v=5tqbgIOKa10
Last edited by Progra on Fri Oct 02, 2009 9:05 am, edited 1 time in total.
I suppose you already found out how to read the joystick itself? As part of the somewhat bizarre Great Program Collage, I made a little routine in 24 bytes that reads all directions of a joystick and packs it into one byte. I don't know if it would be helpful to you since you still need to AND bits out of that custom byte to determine which directions are used. With a little more room, I could have done a better routine.Progra wrote:I still need to code [..] the Joystick part
Anders Carlsson
carlsson wrote:I suppose you already found out how to read the joystick itself? As part of the somewhat bizarre Great Program Collage, I made a little routine in 24 bytes that reads all directions of a joystick and packs it into one byte. I don't know if it would be helpful to you since you still need to AND bits out of that custom byte to determine which directions are used. With a little more room, I could have done a better routine.Progra wrote:I still need to code [..] the Joystick part
Code: Select all
LDA #$7F
STA $9122
LDA $9120
ASL A
LDA $9111
EOR #$FF
AND #$3C
BCS J
ADC #$02
J: LSR A
STA $FE
RTS