Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > [C128] Irq question ...
2019-05-07 21:57
Flavioweb

Registered: Nov 2011
Posts: 442
[C128] Irq question ...

How can i make this code run on a C128 exactily at same addressess?
(I hope this isn't too much off-topic here...)
.C:3000  78          SEI
.C:3001  A9 7F       LDA #$7F
.C:3003  8D 0D DC    STA $DC0D
.C:3006  A9 00       LDA #$00
.C:3008  8D 14 03    STA $0314
.C:300b  A9 40       LDA #$40
.C:300d  8D 15 03    STA $0315
.C:3010  A9 FF       LDA #$FF
.C:3012  8D 12 D0    STA $D012
.C:3015  A9 01       LDA #$01
.C:3017  8D 1A D0    STA $D01A
.C:301a  4E 19 D0    LSR $D019
.C:301d  58          CLI
.C:301e  4C 1E 30    JMP $301E

.C:4000  EE 20 D0    INC $D020
.C:4003  EE 21 D0    INC $D021
.C:4006  AD 12 D0    LDA $D012
.C:4009  CD 12 D0    CMP $D012
.C:400c  F0 FB       BEQ $4009
.C:400e  CE 20 D0    DEC $D020
.C:4011  CE 21 D0    DEC $D021
.C:4014  4E 19 D0    LSR $D019
.C:4017  4C 33 FF    JMP $FF33
 
... 7 posts hidden. Click here to view all posts....
 
2019-05-08 09:14
Flavioweb

Registered: Nov 2011
Posts: 442
Because it look a really stupid thing to me...
I take it as last chance. Is a useless waste of cycles.
If i want to use ram under basic i need to set a code in the ram accessible by defalut, then set $FF00 and jmp to irq code.
I'm trying to understand if there is a way to "reconfigure" the bank activated by $00 in $FF00 to keep only kernal ON...
But is just my guess... i don't know if there is a way to do it...
2019-05-08 09:27
Krill

Registered: Apr 2002
Posts: 2804
There isn't.

If the number of cycles is a problem for you, why not disable the ROM altogether and have your own interrupt handler called directly via $fffe/f? Would both consume a minimal amount of cycles and not have the BASIC ROM problem.
2019-05-08 09:53
Krill

Registered: Apr 2002
Posts: 2804
Besides, having interrupt handlers below $4000 (or at $c000+) is a good idea because of the two RAM banks. You really want to enable a common area (configurable to up to 16K) and put your interrupt handlers there, otherwise having interrupt handlers in one bank and the code being interrupted in another could be a bit of a nuisance.
2019-05-08 11:29
oziphantom

Registered: Oct 2014
Posts: 478
yeah its a flaw in the KERNAL sadly.. it should have been something like
ff1c  AD 00 FF    LDA $FF00          - A:00 X:17 Y:00 SP:14   -  IZ 
ff1f  48          PHA                - A:00 X:17 Y:00 SP:14   -  IZ 
ff20  8D 00 FF    STA $FF04          - A:00 X:17 Y:00 SP:13   -  IZ

but then it has issues as well. Another flaw of this is it assumes the Stack is at $100 which isn't always true either.. and can lead to fun "why did the monitor just start" scratching head sessions - the lack of chis on x128 can really hurt sometimes.

I remember Bil Herd saying that post release he ask Fred why he didn't use the MMU, and his response was "Because there are no Kernal only registers", to which Bil responded "Why didn't you tell me.."

The handy thing with the Pre Configs is they don't trash a register, so you could put your IRQ at $3FFD
0:3FFD sta FF02 <- disable BASIC LO, HI,EDITOR,MONITOR
0:4000 pha
0:4001 tax
.....
You need to set up the PreConfigs to be what you want first, but it only adds 4 clocks
2019-05-08 12:38
Flavioweb

Registered: Nov 2011
Posts: 442
WTF they choosed to force ROMS ON anyway!?!
If i disable the roms and computer crashes ... are just my businness!
If i want to setup a IRQ under ROMS the only way is to disable kernal... or put a "trampoline" in a ram area...
If i need kernal in other parts of my code, outside the irq, the only solution is to have a trampoline somewhere...
/o\
2019-05-08 13:40
Oswald

Registered: Apr 2002
Posts: 5007
well trampoline it, you only waste some bytes in ram, you can even enter the rom irq faster by bypassing some of it.
2019-05-08 13:58
oziphantom

Registered: Oct 2014
Posts: 478
If you know its not going to be used, you can set up the JMPFAR routine $02/$03/$04 bank lo hi and just point the IRQ vector to x:02e3
2019-05-08 13:59
Krill

Registered: Apr 2002
Posts: 2804
Just have a two-fold approach.

- KERNAL disabled would go to your actual interrupt handler directly via $fffe/f.
- KERNAL enabled would go to the ROM interrupt handler, then to the trampoline via $0314/5, which would then go to the actual interrupt handler.

This way, you're only using the cycles you really need to use while allowing both KERNAL on and off.
2019-05-08 13:59
oziphantom

Registered: Oct 2014
Posts: 478
But yes, welcome to the 128, it has ROM EVERYWHERE, however you can switch out the CHARGEN EVERYWHERE as well which is nice.
2019-05-08 17:48
JackAsser

Registered: Jun 2002
Posts: 1987
Quote: Just have a two-fold approach.

- KERNAL disabled would go to your actual interrupt handler directly via $fffe/f.
- KERNAL enabled would go to the ROM interrupt handler, then to the trampoline via $0314/5, which would then go to the actual interrupt handler.

This way, you're only using the cycles you really need to use while allowing both KERNAL on and off.


This is exactly what I do in EotB and my oen handler mimics the kernel so that timing is the same (not c128 related)
Previous - 1 | 2 - 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
csabanw
MAT64
iceout/Avatar/HF
K-reator/CMS/F4CG
Mr. SID
macx
psych
Guests online: 375
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 No Bounds  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 The Ghost  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 Party Elk 2  (9.7)
2 Cubic Dream  (9.6)
3 Copper Booze  (9.5)
4 Rainbow Connection  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Onscreen 5k  (9.5)
7 Dawnfall V1.1  (9.5)
8 Quadrants  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Birth of a Flower  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Nostalgia  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Diskmag Editors
1 Jazzcat  (9.4)
2 Magic  (9.4)
3 hedning  (9.2)
4 Newscopy  (9.1)
5 Elwix  (9.1)

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