COMMODORE PLUS/4 WORLD
  Home  Search  Games  Tapes  Covers  Cheats  Maps  Software  New Stuff 
 Hall Of Fame  HVTC  Game Endings  Solutions  Remakes  Publications  Magazines  Effects  Top List 
 Members  Groups  Features  Plus/4 Encyclopedia  Hardware  Tools  Options  Forum 
Login
Back to forumReply To This TopicGo to last reply

Posted By

Stinaris
on 2017-01-13
17:51:15
 VB interrupt. How do you get it to trigger?

Hi,
My first computer was a plus/4 way back in 1984/5 (can't remember exactly) which died after 6 weeks and was replaced with a C64, after some basic programming and a foray into machine code.
On the C64 I wrote a few programs in assembler and messed about with sprites in the border, 1 & 4 bit sampling and other such shenanigans.

I miss my plus/4 and I'd really like to write something fun for it. So I thought I'd "knock out" a game. So I get so far and try to generate a vertical blank interrupt. Can I get this to trigger. Not a chance. My rasters work fine. My timers work fine. But VB why are you being so difficult. Any help graciously received before I stick hair back in my head.

Posted By

Csabo
on 2017-01-13
20:31:50
 Re: VB interrupt. How do you get it to trigger?

(When questions like this come up, I'm always lamenting what crappy state our knowledge base is in - this should be the topic to check, but currently it barely has anything.)

Hi Stinaris,

I don't think there's such a thing as a VB interrupt, or perhaps I'm not understanding what you mean. $FF09 is the TED register responsible for determining what kinds of interrupts will occurs. There's only 4: raster interrupt (I'd say this is the most common), and 3 more, one for each timer. That's it.

I'm guessing you want to do something at the bottom of the screen, so that you're not drawing on screen while the screen is displayed? The most common way to do that is to set a raster interrupt to $CC (beginning of the lower border).

Let me know if this is what you meant. Otherwise good luck with your game, I hope it comes to fruition

Posted By

Mad
on 2017-01-13
21:53:34
 Re: VB interrupt. How do you get it to trigger?

Hi Stinsris,

You said your Rasters are ok and you can't get a VB Interrupt. As far as I know a VB Interrupt is also a Rasterinterrupt on a specific rasterline. So I just try to help with the Rasterinterrupt. Be sure to check the Ultimate Map here at the forum.

First of all it is important if you have rom enabled or ram. If rom is enabled (by writing any value to $ff3e) then your irq vector will be at $0314/$0315 and needs a special ending sequence. If you have ram enabled (by writing any value to $ff3f) then your interrupt vector is at $fffe/$ffff.

irq_rasterline dc.w $0100

irq_install SUBROUTINE
sei ; prohibit interrupts for now
lda irq_rasterline+1 ; rasterline hibyte
ora #$02 ; 2 means rasterirq
sta $ff0a
lda irq_rasterline ; rasterline lobyte
sta $ff0b
lda #irqFFFE & 255
sta $fffe
lda #irqFFFE / 256
sta $ffff
lda #irq0314 & 255
sta $0314
lda #irq0314 / 256
sta $0315
cli ; allow interrupts again
rts

if you just have rom on or off then you need just the $0314 or $fffe part respectively

irqFFFE SUBROUTINE
pha ; fake 0314 return parameters
txa
pha
tya
pha
irq0314 SUBROUTINE
jsr yourIrqCode ; you can write your code here
pla ; that's the code needed for returning from a 0314 interrupt
tay
pla
tax
pla
inc $ff09 ; notify interrupt done (I don't understand this inc $ff09 "trick" (perhaps some could explain this), but that's the code I use for Rasterinterrupts.)
rti

I hope this helps somehow.. It seems you have an other problem, since you wrote that your rasters work. (And the timers.. So you already have some interrupts running.. :))

Edit: I always wanted to write a big thank you to all the guys that made the plus4 architecture more transparent to newbies.. especially big thanks to SVS for the ultimate map from here. If that information would have been there in the past, who knows what could have been.. (I suppose for professional programmers there where a lot of information or good books to read, however.)

Posted By

Stinaris
on 2017-01-14
03:37:38
 Re: VB interrupt. How do you get it to trigger?

Thanks for your replies.

Sorry for my vague post. I'm actually writing for the C16. I really fancy a challenge. I had to abandon one game as I basically ran out of memory just generating the graphics and one game engine. So I decided to choose a game with a single game engine.
Currently I'm using address $0314/315 to generate my raster interrupts scrolling only the top 20 char lines with the score in the bottom 5 lines. Sadly the processor doesn't have the grunt to shift 800 chars without tearing so I doubled buffered the screen and colour memory in $0c00/$0800 and $3400/$0300 respectively.

So I would like to shift the buffer during the vertical blank so I set the vectors in $0312/0313 as it looked like the obvious choice but there is no specific enable flag which led me to assume that it would use the same flag as the raster.

The plus/4 programmers reference manual is quite good but lacking compared to the c64 version.

Posted By

Mad
on 2017-01-14
07:50:51
 Re: VB interrupt. How do you get it to trigger?

Ok, I looked into the rom dissasembly and jmp ($0312) is only called once in the rom at $ce3f, at an address where the normal interrupt ($0314) normally finishes. If you do a $0314 rasterinterrupt and want everything including basic to behave normal afterwards, you should jmp to the rom address at $ce0e to finish your interrupt (instead of popping the registers and rti). So I suppose the "vertical blank interrupt" is just an extension of the normal $0314 interrupt. Perhaps it's used for the basic splitscreen (does anyone here know this?).

If you want to scroll the whole screen in an interrupt and have other interrupts enabled this could be a little tricky. Most of the times I do the hardscroll (e.g. the ramshift) in the mainloop (waiting for a specific rasterline before), because it doesn't really make a difference and you have a simple way to do other stuff in the rasterirq.

If you want to do it in the irq, than you need nested irqs (if the interrupts overleap), which is a bit tricky. You need to cli (i think. clear $ff09 also) at your interrupt call, set the interrupt vector to a new address and write a new rasterlineposition.

(btw. if you use yape you can do a rom listing in the monitor by "d 0000 ffff file.asm".

Posted By

MMS
on 2017-01-14
13:07:08
 Re: VB interrupt. How do you get it to trigger?

Just a lame question: the NTSC speedup on the borders could not help here? It may provide some extra memory bytes to be moved in a cycle. But I am not an expert inthe topic.

"The Plus/4's PAL model may also be switched to NTSC mode by disabling the screen which sets the CPU frequency to 2.22 MHz[10] (this is 115% faster than C64's maximum speed). So a Plus/4 (PAL) is one of the fastest 6502 based computers for raw calculations. This is true for programs in machine code..."
I think Litwr summarized it somewhere, but could not find the topic.

Posted By

gerliczer
on 2017-01-14
14:05:04
 Re: VB interrupt. How do you get it to trigger?

Just a lame question: the NTSC speedup on the borders could not help here? It may provide some extra memory bytes to be moved in a cycle. But I am not an expert inthe topic.

It completely f*cks up screen generation so what could go wrong doing it?

Posted By

MMS
on 2017-01-14
14:36:16
 Re: VB interrupt. How do you get it to trigger?

Just for clarification: I mean just use for the copy after IRQ the area out of normal screen, switch off srceen and switch to NTSC.

You can switch back to PAL before next screen started to be drawn.

Posted By

Stinaris
on 2017-01-14
14:43:21
 Re: VB interrupt. How do you get it to trigger?

Basically I'm spreading the screen double buffering over 5 separate iterations.
(I'm scrolling Right to Left)

Raster Interrupt at $04 position (1st)
Copy 160 chars from buffer 1 to Buffer 2 (or vice versa)

Raster Interrupt at $04 position (2nd)
Decrease Scroll reg by 2 (using multi-colour and don't know of a better way)
Copy next 160 chars from buffer 1 to Buffer 2 (or vice versa)

Raster Interrupt at $04 position (3rd)
Copy next 160 chars from buffer 1 to Buffer 2 (or vice versa)

Raster Interrupt at $04 position (4th)
Decrease Scroll reg by 2 (using multi-colour and don't know of a better way)
Copy next 160 chars from buffer 1 to Buffer 2 (or vice versa)

Raster Interrupt at $04 position (5th)
Copy next 160 chars from buffer 1 to Buffer 2 (or vice versa)

Raster Interrupt at $04 position (6th)
Music Player Interrupt
Decrease Scroll reg by 2 (using multi-colour and don't know of a better way)

Raster Interrupt at $04 position (7th)

Raster Interrupt at $04 position (8th)



I may have to spread the copy over a number of interrupts or move it out of the interrupts completely.

Posted By

gerliczer
on 2017-01-14
15:48:50
 Re: VB interrupt. How do you get it to trigger?

I'm not quite sure what you are trying to do Stinaris, but this code

	org $1001-2
dw $1001

dw nextln, 2017 ; second word is line number
db $9E
if start > 9999
db "0"+start/10000
endif
db "0"+(start/1000)%10,"0"+(start/100)%10,"0"+(start/10)%10,"0"+start%10,0
nextln db 0,0

start
sei
sta $FF3F
lda #$FF
cmp $FF1D
bne *-3
lda #4+19*8
sta $FF0B
lda #2
sta $FF0A
asl $FF09
lda #lo(irq)
sta $FFFE
lda #hi(irq)
sta $FFFF
cli
jmp *

irq
asl $FF09
inc $FF19
ldx #0
loop
lda $0801+000,x
sta $0800+000,x
lda $0801+040,x
sta $0800+040,x
... imagine the rest here
lda $0801+760,x
sta $0800+760,x
inx
cpx #39
bne loop
dec $FF19
rti

finishes copying quite swiftly. Code was written in Csabo's Plus4IDE. Copying starts five character rows before screen end. And if there is nothing in the ROM that you need to use no matter what in your program, then you're better off paging it out.



Posted By

Csabo
on 2017-01-14
15:31:18
 Re: VB interrupt. How do you get it to trigger?

Yep, that looks pretty standard, should be fine.

Perhaps the issue for Stinaris (do I have the name right?) is the memory footprint? He did say that he gave up on the first game because he ran out of memory. In this loop, the rows are "unrolled". It could be done with fewer bytes, but at the cost of more CPU cycles. (And of course it could be speed optimized too, no indexing at all, but that would take a LOT more memory.)

Posted By

gerliczer
on 2017-01-14
15:43:19
 Re: VB interrupt. How do you get it to trigger?

Well, with all the boiler-plate code and BASIC header it takes less than 200 bytes altogether. That shouldn't cause any memory issues, yet it still runs reasonably quick.

Posted By

Mad
on 2017-01-14
17:49:26
 Re: VB interrupt. How do you get it to trigger?

Stinaris it's always better to put as much lda and sta like gerliczer suggested into one loop. So you have the dex,bpl not taking too much time. A loop looking like this:
ldx #$00
.again
lda $4444,x
sta $4444,x
inx
bne .again
takes more cycles than a loop which processes several packets at once like gerliczers version (and it seems to copy the whole screen there ($400*2), you can do this in one frame (the version by gerlizcer is missing the second $400 though??). I really don't know why you only copy 160 characters per frame, there should be a lot more possible. If you do have tearing, than the selection of the start rasterline could also be crucial..
Turrican for instance (as far as I remember) just copies portions, so that the rasterbeam always doesn't intersect the copying.
However, if you have done your first plus/4 game I would be really curious about it .. There aren't so many new prods like on the C64..

Posted By

Csabo
on 2017-01-14
18:31:07
 Re: VB interrupt. How do you get it to trigger?

I assumed the $0800 was just there as an example, and the actual code would be copying the screen memory (wherever that may be). The same color could be fine for a simple game (assuming multicolor), so you could get away with that. Dex, Gwnn, Sanxion all do this, just to name a few.

(Also, off topic, you guys keep trying to link to his name, but that doesn't work, you end up with empty links.)

Posted By

Mad
on 2017-01-15
00:33:41
 Re: VB interrupt. How do you get it to trigger?

At least so it's colored.. Dunno I think he don't need to scroll the color memory so gerliczers routine is right by copying just these few bytes.. Let's see if he finally can do something with it. Most probably there is a bug elsewhere in the code which slows it down.

Posted By

gerliczer
on 2017-01-15
01:52:01
 Re: VB interrupt. How do you get it to trigger?

/OFF

The site behaviour earlier was like when you linked the name of an unregistered poster, it gave back the list of the person's posts. Or at least that's how I remember it. So then nowadays it is useless. OK. Will refrain doing so. If I can.

/ON

The 800 bytes in my code was not by mistake. He was talking about exactly that amount, first in his post on 2017-01-14 03:37:38, where it was explicitly written, and for a second time in his post on 2017-01-14 14:43:21, where it comes from the 5 times 160 characters. Although, this latter gives room to a different interpretation.

Posted By

Mad
on 2017-01-15
08:56:16
 Re: VB interrupt. How do you get it to trigger?

Right. @Stinaris, you need to clear the second bit of $ff13 to have the speed of the processor almost doubled. Perhaps you forgot that or wrote the wrong value. Dunno what's the default value at startup. TryLda $ff13And #%11111101Sta $ff13That should work, can't test it atm.. Perhaps that helps. And sorry for this formatting :)..

Posted By

Stinaris
on 2017-01-15
11:01:07
 Re: VB interrupt. How do you get it to trigger?

Thank you so much for all the responses. I didn't realise the 264 series scene was so vibrant.

@MAD - Thanks for that. The PRG says $FF13 bit 2 is "Single Clock Set" and that is it. Seems like an important register!!

You are correct about the 800 bytes. it's the first 20 rows that I am scrolling only.

For speed each 160 characters I was copying I setup zero page addressing. So $0c01 and $3400 set 1 and $3401 and $0c00 set 2.

This was then repeated for each of the 5 copy blocks. so $0c01 + #160 and $3400 + #160 set 2 etc etc.

Now when I did this I was still getting some tearing. However after some further investigation it looks like the zero page address I was using for set 3

e.g.
LDA $41
STA $10
LDA #$0d
STA $11

; $12-$13 - $3540
LDA #$40
STA $12
LDA #$35
STA $13

; ---------------------
; 3 : $24-$25 - $3541
LDA #$41
STA $24
LDA #$35
STA $25

; $26-$27 - $0d40
LDA #$40
STA $26
LDA #$0d
STA $27

Appear to used by the Kernal.
Now this may be untrue but they are certainly not what I set them to and I can see no code that would manipulate them (barring any sneaky little bugs).

So I'm going to be less worried about speed and get it working using know and tested zero page addresses.

Posted By

Stinaris
on 2017-01-15
11:02:43
 Re: VB interrupt. How do you get it to trigger?

I'm also currently resurrecting my homepage as Blueyonder homepages have been removed.
Nice of Virgin to let me know.

Posted By

gerliczer
on 2017-01-15
11:35:25
 Re: VB interrupt. How do you get it to trigger?

Oh, what a bummer! I screwed up my example code and scrolled the colour memory instead of the character memory.

Hey, Stinaris. Indirect addressing is way slower that absolute indexed so it is not too surprising that it consumes that much time to do the copying. Furthermore, the "safe area" on the zero page is something like $D0..$E8. Consult with your copy of the Ultimate Map.

Posted By

Stinaris
on 2017-01-15
12:29:18
 Re: VB interrupt. How do you get it to trigger?

I was a little concerned about unrolling the code as in reality there is much less than 16KB available.

2K for colour map and screen map screen 1
2K for colour map and screen map screen 2 (Double Buffer)
2K Character set
1K Zero page
Probably 1Kb for music and fx.

Leaves about 8KB.

Now I'm quite good at condensing stuff down to the essence but there are limits


It's interesting that reviews of C16 games make reference to things like "There's no title page".
With 8KB left I'm not surprised. The character set for my title alone take 37 characters.
That's fine for something like a C64 with abundant memory but not for the C16.

Posted By

Stinaris
on 2017-01-15
12:29:49
 Re: VB interrupt. How do you get it to trigger?

BTW How do I display graphics in my posts. Do I have to be a member?

Posted By

Mad
on 2017-01-15
12:58:02
 Re: VB interrupt. How do you get it to trigger?

I don't know about the graphics, however gerliczer is right about the slow zeropage addressing mode. The best ressource for cycles i know is this site by graham http://www.oxyron.de/html/opcodes02.html. Sorry my phone makes "crap" out of links.

Posted By

Csabo
on 2017-01-15
13:15:59
 Re: VB interrupt. How do you get it to trigger?

Strinaris, as a guest, you can still include link to a free image host like imgur (wrapped in [url] ... [/url] tags).

Posted By

Stinaris
on 2017-01-16
13:14:49
 Re: VB interrupt. How do you get it to trigger?

Wow it has been a long time.

Absolute addressing for LDA and STA takes only 4 cycles. But Indirect Index address takes 5 & 6 respectively.

I'll modify my code to use absolute addressing.

And stick the $FF13 jobbie in.

Posted By

Stinaris
on 2017-01-16
14:34:16
 Re: VB interrupt. How do you get it to trigger?

OK I've removed the zero page addressing and used absolute indexed.

This made no difference. However I found the bug.
A compare was wrong and I was doing the copy during the upper raster and not the lower. Hence the appalling tearing.

Epic Fail :-/

Thanks for everyone's input. I can now crack on with the main game engine now that my scroll routine is as smooth as silk.

Posted By

Stinaris
on 2017-01-16
14:38:37
 Re: VB interrupt. How do you get it to trigger?

Testing posting an image. This is the current state of play with the graphics.

http://i38.photobucket.com/albums/e109/grahampickard/DemoScreenMockup_zpshtkftkew.png

Posted By

Csabo
on 2017-01-16
15:18:49
 Re: VB interrupt. How do you get it to trigger?

(I fixed your post, sorry if I wasn't clear above: you have to put your URL in ... tags, no attributes. See the "Forum Help" link at the top of the page when you're posting.)

Ghouls 'N Goblins? Oh wow, that's going to be a hot topic It's been discussed on the form a lot of times, the sentiment is that our machine deserved something better than the official conversion (Ghosts 'n Goblins) which is... well, crappy. If we're going to get a good conversion, I would rather it wouldn't be 16K, but of course it's up to you

Posted By

Stinaris
on 2017-01-17
04:14:21
 Re: VB interrupt. How do you get it to trigger?

I purposely called it Ghouls'n Goblins as I didnt want to create to much expectation over a "true" Ghosts'n Goblins.
At least not until I've had a bit more practice. It's been nearly 30 years since my last excursion into 6502 and that was on the C64.

It is going to be a Ghost'n Goblins inspired game but designed with the limitations of 16k in mind. Thanks to you guys I've now got an extra 2k to play with without the need for double buffering

Posted By

KiCHY
on 2017-01-17
05:46:20
 Re: VB interrupt. How do you get it to trigger?

You can gain some extra memory if you do a similar way I did with UWOL:
- Compress any data you don't need the same time. For example, level data, multiple charsets, etc. Exomizer is a very good tool for this.
- Use a cross compiler on PC for developing and start your code below $1000 (even from $0200, but take care of IRQ vectors, etc).
- In case of non-standard load address (below $1000 idea) compress the produced PRG with Exomizer again (BUILD.BAT with a few commands) to get a proper basic RUNnable file, then you can test in emulators.

Posted By

Stinaris
on 2017-01-18
13:04:14
 Re: VB interrupt. How do you get it to trigger?

@KiTCHY
I'm currently using CBM Prg Studio for my development.
And Yape 1.1.0 as my emulator.

I have a couple of plus4s but neither work anymore.

Posted By

Gaia
on 2017-09-17
13:34:41
 Re: VB interrupt. How do you get it to trigger?

Any progress on this perhaps?

Posted By

Stinaris
on 2017-09-17
17:54:05
 Re: VB interrupt. How do you get it to trigger?

Now the summer is over I will start coding again.

I've switched to a shmup instead. It's been a lot of years since I did 6502 and not on the C16. Not sure my skills are up to a scrolling platformer, yet.
Currently coding and seeing how enthusiastic I can be with the graphics.

16 k really is a very small amount. What a shame they didn't just make 1 264 machine but with more memory. Even 32k would have made life so much easier.

I'll go back to this when I've finished the shmup.
The rasters are rather more complex on the shmup but i sorted those already.



Back to topReply To This Topic


Copyright © Plus/4 World Team, 2001-2017