Commodore 128 Alive!

Commodore 128 => 128 programmers => Assembly => Topic started by: stiggity on December 23, 2010, 05:23 AM

Title: Another set of routines(address) That I can't seem to find..
Post by: stiggity on December 23, 2010, 05:23 AM
I am still working on my program, and have run into another snag. I have found source code for the 64, and there is a call to a routine that calls 3 or 4 c64, under-basic/kernal calls, and i dont understand them. And there not described in "Mapping the 64". I want to post source, and possibly another utter genious can take a look.

ldy   #0
sty   NY
STA $62
STX $63
LDX #$90
SEC
JSR $BC49
JSR $BDDF
JSR $B487
JSR $B6A6
TAX
LDY #0
INX
m1 DEX
BEQ m2
LDA ($22),Y
STA CONV3,Y
CONVFF STA buffer0,Y  ;$0400,Y
; JSR $FFD2
INY
CMP #13
BNE m1
STY NY
EOR #$FF
JMP $AB28
m2  sty NY
  rts


buffer0     .byte     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
NY     .byte     0


the above is the routine i dont understand. I believe it has something to do with converting a 16bit value.
Title: Re: Another set of routines(address) That I can't seem to find..
Post by: stiggity on December 23, 2010, 05:26 AM
I forgot to setup the routine.. this is called prior to all the address's..

NEWENT1 JSR CHRIN  ; LOWBYTE
TAX
JSR CHRIN
NUMOUT JSR "THIS TROUBLESOME ROUTINE I JUST POSTED"
Title: Re: Another set of routines(address) That I can't seem to find..
Post by: BigDumbDinosaur on December 23, 2010, 12:14 PM
You might get more help if you were to comment your source code so someone can figure out what it's supposed to do.  Also, please use the code tags to make it more readable.
Title: Re: Another set of routines(address) That I can't seem to find..
Post by: stiggity on December 24, 2010, 01:32 AM
NEWENT1 JSR CHRIN  ; LOWBYTE
TAX
JSR CHRIN  ; HIBYTE
NUMOUT JSR conv  ;LINPRT  ; PRINT THE BLOCKS

CONV LDY #0
STY COUNTER
STA $62
STX $63
LDX #$90
SEC
JSR $BC49
JSR $BDDF
JSR $B487
JSR $B6A6
TAX
LDY #0
INX
m1 DEX
BEQ m2
LDA ($22),Y
CONVFF STA dir,Y  ;$0400,Y
INY
CMP #13
BNE m1
STY COUNTER
EOR #$FF
JMP $AB28
m2 STY COUNTER
RTS

counter      .byte     0
dir     .byte     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Title: Re: Another set of routines(address) That I can't seem to find..
Post by: Hydrophilic on December 24, 2010, 03:00 AM
You might want to try posting the question under C64 Programming (http://www.commodore128.org/index.php?board=46.0) to find out what those ROM routines are doing.  A C64 ROM dissassembly  (http://www.ffd2.com/fridge/docs/c64-diss.html)might help.  Once we know what it does, finding an equivalent on the C128 should be trivial.

If you just want to print an unsigned 16-bit number, you might try
sta $64 ;high
stx $65 ;low
ldx #$90 ;exponent bias
sec    ;flag positive
jsr $8c75 ;FAC = unsigned 16
jsr $8e44 ;FAC to string at $100

Then you can print the string similar to the code you posted, just loop over the chars, calling $FFD2 until you find a return (13).  Also the BASIC print line# routine at $8e32 should work, but it is slower and will create a temporary string in BANK 1... no point in wasting var space to print a number!
I'm guessing the other parts of the code are printing/copying a BASIC string?  Sorry, I'm not much help with 64 ROM.
Title: Re: Another set of routines(address) That I can't seem to find..
Post by: stiggity on December 24, 2010, 05:07 AM
Hydrophilic:
I appreciate the help. I guess im going to have to use INDFET = $FF74   and index the loop?
how would i set that up? LDA#100 LDX#1 jsr INDFET?

_Curious..
-Steve
Title: Re: Another set of routines(address) That I can't seem to find..
Post by: stiggity on December 26, 2010, 06:19 AM
Hydro..
I tried to print the string at $100, but there is something im messing up. How would i loop over the characters??
-Steve
Title: Re: Another set of routines(address) That I can't seem to find..
Post by: Hydrophilic on December 28, 2010, 05:01 AM
No you don't need INDFET, because $100 is common RAM.  The problem is likely the string is terminated with 0 instead of 13... sorry for leading you astray!

Here is a quick example

. 01400  lda #$00 ;set bank 15
. 01402  sta $ff00
. 01405  lda #$0d ;print new line (be pretty)
. 01407  jsr $ffd2

. 0140a  lda #$19 ;example # to print ($1966)
. 0140c  ldx #$66 ;guess the decimal value and win!

;convert to decimal (without BANK1 string waste)
;see previous post for comments
. 0140e  sta $64
. 01410  stx $65
. 01412  ldx #$90
. 01414  sec
. 01415  jsr $8c75
. 01418  jsr $8e44

;print decimal string
. 0141b  ldy #$00
. 0141d  lda $0100,y ;get char
. 01420  beq $1428 ;end of string
. 01422  jsr $ffd2 ;print char
. 01425  iny    ;next char
. 01426  bne $141d ;loop

. 01428  rts     ;still in Bank 15

You don't have to use Bank 15, but you need BASIC High ROM and KERNAL ROMs active.  You only need the KERNAL if you want to print the string.
Title: Re: Another set of routines(address) That I can't seem to find..
Post by: stiggity on December 28, 2010, 06:20 AM
Hydro:
Yeah, thats what i was thinking, but it must be something with the rest of this small program im working on. I'm going
too fiddle around with it. But, thanks a bunch.

Title: Re: Another set of routines(address) That I can't seem to find..
Post by: stiggity on January 02, 2011, 11:29 AM
hydro:
Is ZP value $d3 or ascii 211 in common RAM?
I use it to scan a press of the c= key?
from $9000 can i simply lda$d3 cmp#02 etc.. or do i have to get INDFET
-Steve
Title: Re: Another set of routines(address) That I can't seem to find..
Post by: Hydrophilic on January 02, 2011, 05:05 PM
Unless you change the MMU settings, everything below $400 (most important zero page and stack) are Common RAM, so no need for INDFET/INDSTA.
Title: Re: Another set of routines(address) That I can't seem to find..
Post by: stiggity on January 03, 2011, 06:00 AM
Hydro?

If im using a jump table @ $1300, which does a LDA#$0E, STA$FF00,JMP$9000 is that changing the MMU settings?

-Steve
Title: Re: Another set of routines(address) That I can't seem to find..
Post by: stiggity on January 03, 2011, 06:07 AM
would  $0A0F be in common RAM? i dont think so... how would i re-write a

LDA $0A0F
CMP xyz

-Steve
P.S
The BBS Program is coming along nice. Except that punter, and multi-punter start/transfer/end just like there supposed to, but the file transfered doesnt work.. ;(
Title: Re: Another set of routines(address) That I can't seem to find..
Post by: stiggity on January 03, 2011, 07:33 AM
Hydro!!!
Even thouig I own the 64PRM and 128PRM im having a tough time decyphering a certain ZP pointer.
my Multi Punter (Originally in c64 source) uses $64 extensively. What would be the 128 equivalent?

-Steve
Title: Re: Another set of routines(address) That I can't seem to find..
Post by: Hydrophilic on January 03, 2011, 11:19 AM
Quote from: stiggity
...which does a LDA#$0E, STA$FF00,JMP$9000 is that changing the MMU settings?

Well technically yes, but I meant changing things in the $d505-$d50a area, which control things like Common RAM, zero page, and stack page.  Any store to $ff00~$ff04 will only change the current "overlay" (ROM or I/O on top of RAM), but will not effect Common RAM, zero page, or stack.

Quote from: stiggity
would  $0A0F be in common RAM? i dont think so... how would i re-write a

LDA $0A0F
CMP xyz
You're right, if it is not below $400, then it is not Common RAM (unless you muck with the $d50x registers).

If you are not in BANK 0, (or a bank that has access, like BANK 15 below $4000) then you need to use INDFET... or even faster (no KERNAL required) is to call FETCH at $2a2 (this is Common RAM).

To use FETCH, set up a pointer in zero page and a value in Y register... like if you wanted to do LDA (z),Y.  Store "z" into $2aa.  Then put an MMU value (like $0E of your example) into the X register.  Finally JSR to $2a2.  It will return the value of LDA(z),Y in memory config X.  However, the X will be changed.

Finally, you're asking about $64 on the C64... sorry, I don't know that much about the C64, except that it would have something to do with BASIC and not the KERNAL.
Title: Re: Another set of routines(address) That I can't seem to find..
Post by: stiggity on January 03, 2011, 11:58 AM
Hydro-
Let's say i want to use the INDFET routine to read _from_ $0A0F, how would i set that up. I'm only familiar with setting up a Zero page value, I.E. #$BB, #$52+1 etc. like LDA#$FD,LDX#1,JSR$FF74 how do i setup the lo/hi for $0A0F and "string it" or simply find the valuer of that address?

-Steve
Title: Re: Another set of routines(address) That I can't seem to find..
Post by: Hydrophilic on January 04, 2011, 01:56 PM
It looks like you're half-way there.  Just store the low byte ($0f) into $FD and the high byte ($0a) into $FE.  Then repeat the same code you just mentioned... well, be sure to set the Y register to zero.
Title: Re: Another set of routines(address) That I can't seem to find..
Post by: stiggity on January 05, 2011, 03:08 AM
Hydro:
Thanks for all the help, but i do have _another_ newb question..
You said store the low byte ($0F) into $FD so i would LDA#$0F, STA$FD? or would I LDA#$0F sta #$FD im getting my immediate mode confused..
-Steve
Title: Re: Another set of routines(address) That I can't seem to find..
Post by: stiggity on January 05, 2011, 03:19 AM
It friggin works!!! YAY!!ehehhehehe ;)
Hydro, dude.. i big-time appreciate the assistance. My entire error was an rs232 error, and the transfer wasn't flowin like it was supposed too. I just whipped 2 files back and forth and the transfer works, and each file is correct i length, content.. thanks alot!!

-Steve
Millennium 128 BBS v1
EhPortal 1.34 © 2026, WebDev