Login
Back to forumReply to this topicGo to last reply

Posted By

Sdw
on 2009-01-05
07:02:45
 TED-gurus, help me out (stable IRQs, FLI, 4x4 mode etc.)!

I have been playing around a bit with Plus/4 demo-coding, and have got some simple stuff working.
But to get the real good stuff going, I'll probably need to start messing around more with the TED-features.

Things I'm interested in:

* How many cycles are there per raster line?
* How does character fetch work and how many cycles does it steal (ie. is it similar to the C64?)
* How does one set up a stable raster IRQ?
* I've seen from posts here that FLI-like mode is possible on the Plus4. Is it similar to how it works on the C64 (mess around with scroll-register to force character fetch every line)?
* I am guessing that it should also be possible to set up a 4x4-screen using FLI every 4th line? Can this be done by setting an IRQ to trigger every 4th line, thereby giving free CPU-time for effect code inbetween...?

For the C64 there is plenty of examplecode over at codebase64.org, but for the Plus/4 I've not seen any place with publically released source. Anyone have any source snippets implementing anything of what I've mentioned above willing to share?

Posted By

Csabo
on 2009-01-05
09:43:27
 Re: TED-gurus, help me out (stable IRQs, FLI, 4x4 mode etc.)!

Some quick replies off the top of my head.

* Normally 65, also see here this post
* Similar to the C64, but we have 2 badlines. See above and the FLI topic in the KB.
* An example is in the sample .ASM files that come with Plus4IDE.
* There are similarities... See FLI from before
* Yes, it's possible. Yes, that way is possible too.

For some demo and game sources, see my releases. I released the source of everything I wrote (that aren't C64 conversions).

Posted By

Sdw
on 2009-01-05
10:10:58
 Re: TED-gurus, help me out (stable IRQs, FLI, 4x4 mode etc.)!

Thank you, much interesting stuff there!
The FLI article explaining the two-line fetch was a good read.

I also did some googling and found this article:
http://www.canberra.edu.au/~scott/C=Hacking/C-Hacking12/gfx.html

If that is accurate, it should be 57 cycles/line.

The switching of CPU speed was news to me as well. So it is 885kHz on screen and 1.71MHz in border, or is that oversimplifying it?

Posted By

Csio
on 2009-01-05
10:57:11
 Re: TED-gurus, help me out (stable IRQs, FLI, 4x4 mode etc.)!

4x4 zoom4 mode irq - stolled from bubis fli conv. cause it is canceled

colorBufferChange:
.byte 1
newColorRam0:
.byte 0
newColorRam1:
.byte 0

;XR: $ff14 erteke a paros sorokhoz - paired line
;YR: $ff14 erteke a paratlan sorokhoz - non paired line
.proc initIrq

sei
stx newColorRam0
sty newColorRam1
lda $ff06
sta yscroll0
eor #4
sta yscroll1

;timer beallitas

lda #<timeingIrq
sta $fffe
lda #>timeingIrq
sta $ffff
lda #2 ;raster irq
sta $ff0a
lda #5
sta $ff0b
lda $ff09
sta $ff09
cli

w: lda counter ; wait
beq w

sei

lda #<rasterIrq
sta $fffe
lda #>rasterIrq
sta $ffff
lda #2
sta $ff0b

lda $ff09
sta $ff09
rts

timeingIrq:
sta tempa
lda $ff1e ;stabilizaljuk a rasztert - stab. the raster happy
lsr
lsr
sta reljump
reljump = *+1
bpl *+2 ;vigyazni kell, hogy a kov. nop ugyanebben
cmp #$c9 ;a 256 byteos blokkban legyen, kulonben
cmp #$c9 ;elromlik az idozites! - ezt a csabo maj lefordittya
cmp #$c9
cmp #$c9
cmp #$c9
cmp #$c5
nop
; stabil!

bit $ffff ;53 cycle
bit $ffff
bit $ffff
bit $ffff
bit $ffff
bit $ffff
bit $ffff
bit $ffff
bit $ffff
bit $ffff
bit $ffff
bit $ffff
bit $ff
nop

lda #<(8*57)
sta $ff00
lda #>(8*57)
sta $ff01

sta counter

inc $ff09
jmp irqe


rasterIrq:
pha
lda #<zoom4Irq
sta $fffe
lda #>zoom4Irq
sta $ffff
lda #8 ;timer1 irq
sta $ff0a
lda #25
sta counter
inc $ff09

;buffer change
lda colorBufferChange
beq nobch ;no change
lda newColorRam0
sta $ff14
sta colorRam0
lda newColorRam1
sta colorRam1
lda #0
sta colorBufferChange
nobch:

.ifdef effectInIrq

inProgress = *+1
lda #0
bne running

inc inProgress

cli
txa
pha
tya
pha
jsr effectInIrq
pla
tay
pla
tax

dec inProgress

running:
.endif

pla
rti

counter:
.byte 0


zoom4Irq:
sta tempa
colorRam1 = *+1
lda #0
sta $ff14
yscroll1 = *+1
lda #0
sta $ff06
inc $ff09
lda #0 ;igy kell csak ket sornyi bitmap - cause enought only 2 charline bitmap
sta $ff1b
dec counter
bne out

lda #<rasterIrq
sta $fffe
lda #>rasterIrq
sta $ffff
lda #2 ;raster irq
sta $ff0a

.ifdef player
stx tempx
sty tempy
jsr player
tempx= *+1
ldx #0
tempy= *+1
ldy #0
.endif

out:
yscroll0 = *+1
lda #0
sta $ff06
colorRam0 = *+1
lda #0
sta $ff14
irqe:
tempa = *+1
lda #0
rti

.endproc

Posted By

gerliczer
on 2009-01-05
12:23:08
 Re: TED-gurus, help me out (stable IRQs, FLI, 4x4 mode etc.)!

The number of CPU cycles per rasterline varies a lot depending on the CPU clock mode (single or double clock) and TED operation (border, normal line, badline). In double clock mode there are 109 in the border, 65 in normal lines and 22+3 in badlines. In single clock mode there are 57 in border, 57 in normal lines and 14+3 in badlines. The double clock/single clock mode roughly works through TED allowing the CPU to step its inner state either in every or every second clock cycle. Someone should upload here the old plus/4 mailing list's messages. There were a very detailed post by Crown about this.

Making an interrupt in every 4th line for a 4x4 mode may be an overkill. Making it in every 8th line in the middle of the char row should be enough, passing the char row boundary makes TED changing some necessary pointers anyway.

Trying the debugger of YAPE and plus4emu also may help understand how these things work.

I hope that this will help.

Posted By

Sdw
on 2009-01-05
12:51:59
 Re: TED-gurus, help me out (stable IRQs, FLI, 4x4 mode etc.)!

Thanks Csio for that piece of code, very helpful! I think I understand how it works, by first stabilizing the IRQ, then running a raster-IRQ each frame that then triggers a timer-IRQ that does the FLI-thing 25 times (just as gerliczer siad, it's only necessary with one IRQ per 8 lines).
Beautiful, works like a charm!

Posted By

Csabo
on 2009-01-06
08:21:15
 Re: TED-gurus, help me out (stable IRQs, FLI, 4x4 mode etc.)!

So, when can we expect the new release? happy

Posted By

Sdw
on 2009-01-06
08:57:04
 Re: TED-gurus, help me out (stable IRQs, FLI, 4x4 mode etc.)!

If all goes according to plan, maybe sometime this year, but I make no promises! happy



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024