[TI ASM] Port $06 and the TI FONT

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Post Reply
chickendude
Extreme Poster
Posts: 340
Joined: Fri 07 Jul, 2006 2:39 pm

[TI ASM] Port $06 and the TI FONT

Post by chickendude »

Ok, so i was trying to figure out where TI stores the sprites for it's large font, as i can't really think of any other way to draw the large font to the graphbuffer or some other place to play around with it before displaying it to the screen. Well, after a long day spent inside PindurTI's dissassembler following through the maze of instructions, i think i am really close to figuring everything out. It seems that if you output the value $27 to port 6, it loads the font map to $4506 (well, 8 bytes past that, as the value 0 is the null termination and doesn't display anything). I'm really uncertain as to what port 6 actually does, something to do with swapping the pages in the calculators memory? I noticed that the bcall function (if you would call it that) made use of port 6, so are the bcall routines separated into different pages? Where can i read more about how all of this works?

Ah, but i did get the routine i wanted sorted out:
Image
or:

Code: Select all

Group1	.equ $FE
Group2	.equ $FD

dEnter	.equ 254


Main:
	ld hl,$450E
tifont:
	push hl
	in a,($06)
	push af

	ld a,$27
	out ($06),a

	ld bc,7
	ld de,copysprite
	ldir

	pop af
	out ($06),a

	ld l,0
	ld a,0
	ld b,7
	ld ix,copysprite
	call ionputsprite		;display it!
	call ionfastcopy
	bcall(_cleargbuf)	

	pop hl
keyLoop:
	ld a,0ffh

	out (1),a
	ld a,Group2

	out (1),a

	in a,(1)


	cp dEnter
	 ret z

	ld a,Group1

	out (1),a

	in a,(1)

	cp $FF
	jr z,keyLoop
	
	ld de,8
	rra
	rra
	jr c,$+4
	sbc hl,de					;left was pressed
	rra
	jr c,$+3
	add hl,de					;right was pressed

	 jr nz,tifont
	ret
copysprite:
.db 0,0,0,0,0,0,0
And the reason i had wanted it initially was to use it as a sort of custom font routine:
Image

Code: Select all

Group1	.equ $FE
Group2	.equ $FD

dEnter	.equ 254





Main:
	bcall(_cleargbuf)
	ld de,0105h
	ld (bigPenRow),de
	ld hl,textLabel
	call drawFont
	bcall(_getkey)
	ret

drawFont:
	push hl
	ld de,$4506

	in a,($06)
	push af

	ld a,$27
	out ($06),a
	
	ld a,(hl)
	ld l,a
	ld h,0
	add hl,hl
	add hl,hl
	add hl,hl		;x8

	add hl,de
	ld bc,7
	ld de,copysprite
	ldir

	pop af
	out ($06),a

bigPenRow = $ + 1
	ld hl,0101h
	call drawsprite
	inc l
	call drawsprite
	inc h
	call drawsprite
	dec l
	call drawsprite
	dec h
	call drawsprite
	ld a,h
	ld b,7
	ld ix,copysprite
	call ionputsprite		;display it!
	call ionfastcopy
	ld de,$0600
	ld hl,(bigPenRow)
	add hl,de
	ld (bigPenRow),hl
	pop hl
	inc hl
	ld a,(hl)
	or a			;null terminated
	ret z
	jp drawFont
	
drawsprite:
	ld a,h
	ld b,7
	ld ix,copysprite
	call ionORSprite		;display it!
	ld hl,(bigPenRow)
	ret

copysprite:
.db 0,0,0,0,0,0,0,
textLabel:
.db "Hey Maxcoderz!",0
;-----> Draw a sprite
; b=size of sprite
; l=yc
; a=xc
; ix holds pointer
ionORSprite:
	push ix
	ld	e,l
	ld	h,$00
	ld	d,h
	add	hl,de
	add	hl,de
	add	hl,hl
	add	hl,hl
	ld	e,a
	and	$07
	ld	c,a
	srl	e
	srl	e
	srl	e
	add	hl,de
	ld	de,gbuf
	add	hl,de
putSpriteLoop1:
sl1:	ld	d,(ix)
	ld	e,$00
	ld	a,c
	or	a
	jr	z,putSpriteSkip1
putSpriteLoop2:
	srl	d
	rr	e
	dec	a
	jr	nz,putSpriteLoop2
putSpriteSkip1:
	ld	a,(hl)
	or	d
	ld	(hl),a
	inc	hl
	ld	a,(hl)
	or	e
	ld	(hl),a
	ld	de,$0B
	add	hl,de
	inc	ix
	djnz	putSpriteLoop1
	pop ix
	ret
Note: both of these routines use the ionPutSprite routine (feel free to substitute any XOR routine).
Note2: please don't try these out on your actual calculators (if you do bother to try them out at all!) as i really don't know what i am doing with the ports and on PindurTI i experienced some funky things. I think i fixed them but i've really got no idea! So please, unless you know what you are doing, well.. just be careful!

By ORing each sprite 5 times (once centered, once shifted one pixel left, once shifted one pixel right, etc) then XORing the sprite in the center, there's that cool outline effect :) Plus you don't have to create any extra sprites on your own (and you have access to the full TI ASCII font set)!

EDIT: The Internet i was using crapped out before i could post this, after reading through the replies in the other topic that cleared up quite a few things :)
User avatar
Dwedit
Maxcoderz Staff
Posts: 579
Joined: Wed 15 Dec, 2004 6:06 am
Location: Chicago!
Contact:

Post by Dwedit »

you know, there's also that old "bub_font" routine I made for bubble bobble 85 that contains a packed font with up to 4x5 character image sizes.
You know your hexadecimal output routine is broken when it displays the character 'G'.
User avatar
Dwedit
Maxcoderz Staff
Posts: 579
Joined: Wed 15 Dec, 2004 6:06 am
Location: Chicago!
Contact:

Post by Dwedit »

Wait a minute... You can draw the big font to the graphbuffer easily just by using some other argument to vputs


To draw the large font:

set fracDrawLFont, (iy+fontFlags)
then call vputs.

Source: TI83+ SDK Guide
You know your hexadecimal output routine is broken when it displays the character 'G'.
chickendude
Extreme Poster
Posts: 340
Joined: Fri 07 Jul, 2006 2:39 pm

Post by chickendude »

Dwedit wrote:Wait a minute... You can draw the big font to the graphbuffer easily just by using some other argument to vputs


To draw the large font:

set fracDrawLFont, (iy+fontFlags)
then call vputs.

Source: TI83+ SDK Guide
I came across that too, and i only played with it for a little bit but it didn't seem to want to draw to the graphbuffer, even after running "set textwrite,(iy+sgrflags)". I didn't know if it was just intended to allow the large font to be drawn unaligned. And if it could be drawn to the gbuf, it would be AND'd. I'll go back and see if i can figure out what i did wrong. Writing a custom font routine wouldn't be too difficult for me, i just figured i'd try using/playing around with TI's font in place of drawing my own.. Though BubbleBobble is still one of my favorite games :D
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

As to port 6, http://wikiti.denglend.net/index.php?ti ... s:Ports:06 is probably correct
It's not a hard port, it just does 1 thing, doesn't need any masking and you can safely mess with it as long as you restore its value before doing bcalls or exit
Maybe the font bitmap is stored on page $27?
chickendude
Extreme Poster
Posts: 340
Joined: Fri 07 Jul, 2006 2:39 pm

Post by chickendude »

Thanks for that link! I thought it might be something along those lines (stored on page $27), although Spencer mentioned that it is different in each ROM and i've only got one ROM version to test it out (1.12). I think the bcall Spencer and Benryves mentioned is probably a better alternative (or just making my own font map, as Dwedit suggested).
Post Reply