Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user Rodrigo Yeowtch ! (Registered 2024-11-24) You are not logged in - nap
CSDb User Forums


Forums > CSDb Entries > Release id #141145 : Planet 5200
2015-09-14 18:58
Heaven
Account closed

Registered: Jul 2008
Posts: 102
Release id #141145 : Planet 5200

new CIA 4x4

this is basicly the source I have for 4x4:

;-------- init4x4 ----------------------
;blockbegin



.align $0100

init_4x4
sei
; lda #$35 ...already set
; sta $01

lda #$7f
sta $dd0d
lda $dd0d
ldx #<(fake_nmi)
ldy #>(fake_nmi)
stx $fffa
sty $fffb
ldx #<(timer_test)
ldy #>(timer_test)
stx $dd04
sty $dd05
lda #$11
sta $dd0e
lda #$81
sta $dd0d
.byte $ea,$ea,$ea,$ea,$ea,$ea,$ea,$ea,$ea,$ea
fake_nmi
ldx $dd04
lda #$7f
sta $dd0d
lda $dd0d
plp
pla
pla
cpx #3
beq old_cia
lda #$24 ; bit zp
sta cia_mod
sta cia_mod2
.byte $ea,$ea,$ea,$ea,$ea,$ea,$ea,$ea,$ea,$ea,$ea
.byte $ea,$ea,$ea,$ea,$ea,$ea,$ea,$ea,$ea,$ea,$ea
.byte $ea,$ea,$ea,$ea,$ea,$ea,$ea,$ea,$ea,$ea,$ea
old_cia
ldx #<(nmi)
ldy #>(nmi)
stx $fffa
sty $fffb
ldx #<(timer_a)
ldy #>(timer_a)
stx $dd04
sty $dd05
ldx #<(timer_b)
ldy #>(timer_b)
stx $dc06
sty $dc07
.page
PalTiming
ldx #3
cpx $d012
bne *-3
ldy #9
dey
bne *-1
cmp ($00),y
inx
cpx $d012
beq PalTiming2
cmp ($00),y
PalTiming2
ldy #9
dey
bne *-1
nop
nop
nop
inx
cpx $d012
beq PalTiming4
b_rts = *+1
cmp $60
PalTiming4
ldy #10
dey
bne *-1
nop
inx
cpx $d012
bne PalTiming6
PalTiming6
.endp
pha
pla
pha
pla
cia_mod cmp #$DB
.if !below_io
bit $DB
.fi
lda #$11
sta $dd0e
ldy #5
dey
bne *-1
cia_mod2 cmp $DB,x
.if below_io
bit $DB
.fi
sta $dc0f
lda #$40
sta b_rti

lda #$7f
sta $d019
sta $dc0d
lda $dc0d
ldx #<(vic_irq_start)
ldy #>(vic_irq_start)
stx $fffe
sty $ffff
lda #ras_start
sta $d012
lda #$1b
sta $d011
lda #1
sta $d01a
lda #$34
sta $01
cli
rts

;lda #%00011000
;lda #%00101000

nmi
sta nmi_accu+1
lda #15
.if below_io
sta $01 ; timing critical^
.fi
eor $dc06
sta timeit+1
.page
timeit bpl timeit+2
.byte $a9,$a9,$a9,$a9,$a9,$a9,$24,$ea
.endp

scrmod1 lda #%10101000
sta $d018
d11b lda #$1f
sta $d011
d11a lda #$1b
sta $d011
scrmod2 lda #%10111000
sta $d018


.if below_io
bit $dd0d
lda #$30 ; not timing critical
sta $01
nmi_accu lda #$FF
rti
.else
nmi_accu lda #$FF
jmp b_rti
.fi

.align $0100
vic_irq_start
sta irq_start_accu+1
.if below_io
lda #$35 ; not timing critical
sta $01
.fi
lda #ras_stop
sta $d012
bit $dd0d

lda #$81
sta $dd0d
sta $d019
lda #<(vic_irq_stop)
sta $fffe
.if below_io
lda #$30 ; not timing critical
sta $01
.fi
irq_start_accu
lda #$FF
rti

vic_irq_stop
sta irq_stop_accu+1
.if below_io
lda #$35 ; not timing critical
sta $01
.fi
.if open_border
lda #$13
sta $d011
.fi
lda #ras_start
sta $d012
lda #1
sta $dd0d
sta $d019
lda #<(vic_irq_start)
sta $fffe

.if below_io
lda #$30 ; not timing critical
sta $01
.fi
irq_stop_accu
lda #$FF
rti

question...

what does the .page command do?
2015-09-14 19:04
Flavioweb

Registered: Nov 2011
Posts: 463
".page" check if bytes within ".page" and ".endp" cross the page boundary.
This is needed to avoid to add -1- cycles in "time critical" code.
If boundary is crossed, the compiler should return an error.
2015-09-14 19:05
soci

Registered: Sep 2003
Posts: 479
http://tass64.sourceforge.net/#d_page

"Gives an error on page boundary crossing, e.g. for timing sensitive code."
2015-09-14 19:21
Flavioweb

Registered: Nov 2011
Posts: 463
Seems like
beq old_cia

should be
bne old_cia

Or i'm totally wrong?
2015-09-14 20:57
Heaven
Account closed

Registered: Jul 2008
Posts: 102
Aaah.... So page is NOT .align $100....

Ok.... Now it makes more sense...
2015-09-15 10:24
Heaven
Account closed

Registered: Jul 2008
Posts: 102
Interesting... my unreleased 4x4 plasma works on both models and I did copy & paste 4x4 code from there...
2015-09-15 10:47
Heaven
Account closed

Registered: Jul 2008
Posts: 102
and... to track down such errors Vice debugger is not best compared to powerfull source level cycle exact debugging on A8 and Altirra. ;)
2015-09-15 11:37
Bitbreaker

Registered: Oct 2002
Posts: 504
Depending on your effect the range of jitter may vary, thus the jitter correction might work, no matter what CIA type you have, but when going out of range ($ff or beyond the last NOP on the bpl timeit+2) things might go south, as new and old cia trigger the irq with 1 cycle difference. This also needs to be taken care of on the correction routine.
More precicely, with an old CIA you should take care that the sta nmi_acc+1 takes 4 cycles, and with a new CIA it should only take 3 cylces, so you best transform it into a sta $some_zeropage_location when a new CIA is used.

Also, when timers from CIA 1 and 2 are used, a detection per CIA is needed, as both types can exist on a single board.
2015-09-15 15:50
Ninja

Registered: Jan 2002
Posts: 411
Heaven: you might try something like 'tax; sta debug_page,x' after 'eor $dc06' in the nmi and check what jitter values you actually get. I am quite sure I positioned the timers to handle jitter 0..7, but a) it has been years ago and b) the source has wandered around quite much (even across different assembler versions). And if the timers are started one cycle off, then problems...

Bitbreaker: The timers are started at different cycles to handle the CIA differences.
2015-09-15 16:42
Bitbreaker

Registered: Oct 2002
Posts: 504
Sure, but arent' the resulting counter values one cycle off on an occuring IRQ, depending on CIA type still? So you still have to cope with that offset when eliminating the jitter by reading back for e.g. $dc06, right? Means, 0 .. 7 or 1 .. 8 cycles to compensate.
2015-09-15 18:21
Heaven
Account closed

Registered: Jul 2008
Posts: 102
Good old Atari.... A simple STA WSYNC and I am done ;)
 
... 16 posts hidden. Click here to view all posts....
 
Previous - 1 | 2 | 3 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Impetigo/Crescent
Barfly/Extend
Didi/Laxity
Jetboy/Elysium
psych
DJ Gruby/TRiAD
Conjuror
wil
ArturoDente
da Blondie/Resource
katon/Lepsi De
Yogibear/Protovision
JEZ
Rock/Finnish Gold
Guests online: 131
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Mojo  (9.6)
6 The Demo Coder  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Comaland 100%  (9.6)
10 What Is The Matrix 2  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Party Elk 2  (9.6)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.6)
5 Libertongo  (9.5)
6 Rainbow Connection  (9.5)
7 Onscreen 5k  (9.5)
8 Morph  (9.5)
9 Dawnfall V1.1  (9.5)
10 It's More Fun to Com..  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Nostalgia  (9.3)
5 Censor Design  (9.3)
Top Organizers
1 Burglar  (9.9)
2 Sixx  (9.8)
3 hedning  (9.7)
4 Irata  (9.7)
5 Tim  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.053 sec.