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: 447
[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
2019-05-07 23:27
Krill

Registered: Apr 2002
Posts: 2850
Not sure what your problem is, but the BASIC ROM on C-128 is at $4000, so you want to disable it in order to use the interrupt handler:
lda #$02
sta $ff00
What's the background of your question?
2019-05-07 23:37
Flavioweb

Registered: Nov 2011
Posts: 447
The problem is here:
ff17  48          PHA                - A:00 X:17 Y:00 SP:17   -  I  
ff18  8A          TXA                - A:00 X:17 Y:00 SP:16   -  I  
ff19  48          PHA                - A:17 X:17 Y:00 SP:16   -  I  
ff1a  98          TYA                - A:17 X:17 Y:00 SP:15   -  I  
ff1b  48          PHA                - A:00 X:17 Y:00 SP:15   -  IZ 
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  A9 00       LDA #$00           - A:00 X:17 Y:00 SP:13   -  IZ 
ff22  8D 00 FF    STA $FF00          - A:00 X:17 Y:00 SP:13   -  IZ 
ff25  BA          TSX                - A:00 X:17 Y:00 SP:13   -  IZ 
ff26  BD 05 01    LDA $0105,X        - A:00 X:13 Y:00 SP:13   -  I  
ff29  29 10       AND #$10           - A:20 X:13 Y:00 SP:13   -  I  
ff2b  F0 03       BEQ $FF30          - A:00 X:13 Y:00 SP:13   -  IZ 
ff30  6C 14 03    JMP ($0314)        - A:00 X:13 Y:00 SP:13   -  IZ

at $FF20 kernal set $FF00 to $00 turning on BASIC again...

There is a way to avoid this but having kernal (not BASIC) rom active?
2019-05-07 23:42
Krill

Registered: Apr 2002
Posts: 2850
Ah, i see. Then you either want to disable the KERNAL ROM as well and have your entirely own interrupt handler with the vector at $fffe, or you let the vector at $0314 point to a thunk residing anywhere below $4000, which would disable the BASIC ROM and then jump to the actual handler at $4000.
2019-05-07 23:50
Flavioweb

Registered: Nov 2011
Posts: 447
I need to have kernal on but basic off, using vector at $0314 to point the IRQ routine at $4000...
2019-05-07 23:55
Krill

Registered: Apr 2002
Posts: 2850
Okay, XY problem solving time. What is your _actual_ problem you're trying to solve?
2019-05-08 00:14
Flavioweb

Registered: Nov 2011
Posts: 447
I'm experimenting using CC65 with a mix of C and assembly code.
An IRQ handler that setup one raster irq is called by C code.
Compiled C code starts with:
.C:1c0d  A9 0E       LDA #$0E
.C:1c0f  20 D2 FF    JSR $FFD2
.C:1c12  AD 00 FF    LDA $FF00
.C:1c15  48          PHA
.C:1c16  A9 0E       LDA #$0E
.C:1c18  8D 00 FF    STA $FF00

so ROMS are OFF.
Irq setup code starts at $4xxx and looks like:
.C:4011  A9 7F       LDA #$7F
.C:4013  8D 0D DC    STA $DC0D
.C:4016  78          SEI
.C:4017  A9 44       LDA #$44
.C:4019  8D 14 03    STA $0314
.C:401c  A9 40       LDA #$40
.C:401e  8D 15 03    STA $0315
.C:4021  A9 64       LDA #$64
.C:4023  8D 18 03    STA $0318
.C:4026  A9 40       LDA #$40
.C:4028  8D 19 03    STA $0319
.C:402b  A9 01       LDA #$01
.C:402d  8D 1A D0    STA $D01A
.C:4030  A9 1B       LDA #$1B
.C:4032  8D 11 D0    STA $D011
.C:4035  A9 FC       LDA #$FC
.C:4037  8D 12 D0    STA $D012
.C:403a  AD 0D DC    LDA $DC0D
.C:403d  A9 0E       LDA #$0E
.C:403f  8D 00 FF    STA $FF00
.C:4042  58          CLI
.C:4043  60          RTS

which have a (now i know) useless $FF00 write at $403d.

After CLI at $4042, first time IRQ is triggered i have BASIC rom turned ON by kernal IRQ code... and all fucks up.

There is a way to keep BASIC OFF?
2019-05-08 08:45
Krill

Registered: Apr 2002
Posts: 2850
But why must your interrupt handler start at $4000 and not, say, $3f80? And is that interrupt handler thunk/trampoline i mentioned not an option?
2019-05-08 09:14
Flavioweb

Registered: Nov 2011
Posts: 447
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: 2850
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: 2850
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.
 
... 7 posts hidden. Click here to view all posts....
 
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
CA$H/TRiAD
zscs
d'Arc/Topaz Beerline
Guests online: 154
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Wafer Demo  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Nostalgia  (9.3)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Swappers
1 Derbyshire Ram  (10)
2 Jerry  (9.8)
3 Violator  (9.8)
4 Acidchild  (9.7)
5 Starlight  (9.6)

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