Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Geekboy1011 on March 09, 2014, 10:46:22 pm

Title: Text Box System Module - Brass
Post by: Geekboy1011 on March 09, 2014, 10:46:22 pm
So over the last couple weeks I have been working on a small side project that will be being used in an upcoming project of Iambian's and mine. This project is a Text Subsystem that would be used in an RPG.
It comes with a host of supporting routines to make interfacing with it easier for the end coder

The program is interfaced with 2 Main routines these are DrawBox And PutStr. PutStr Puts the null terminated string pointed to by hd inside the bounded box that has been defined. DrawBox Draws the visual Box around the Text and takes the corner style in A.

The PutStr Routine supports inline modifiers for the text output that is supplemented via a macro.
Mod(Italics,Underline,Flip,Mirror,Inverse,WordWrap) OR any combination of the settings. Which makes adding effects to strings rather easy.

Ok enough Jargon Lets put some examples and screenies :D

.db "Welcome to Cemetech",CrlF,Mod(Italics,Underline),"LTTFW",0
(https://dl.dropboxusercontent.com/u/98196116/TextSys/cemetechltwttf.gif)

.db "This Is right up",CrLf,Mod(Mirror,Flip),"This is not!",0
(https://dl.dropboxusercontent.com/u/98196116/TextSys/mirror.gif)

.db Mod(Inverse),"White",Mod(Clear),"Black",Mod(Inverse),"White",Mod(Clear),"Black",0.db Mod(Inverse),"White",Mod(Clear)," Black",Mod(Inverse),"White",Mod(Clear)," Black",0
(https://dl.dropboxusercontent.com/u/98196116/TextSys/WhiteBlack.gif)

Its' Word Wrapping is rather robust.
(https://dl.dropboxusercontent.com/u/98196116/screenies/animooted.gif)

And it supports style changes by changing a byte in ram :D
(https://dl.dropboxusercontent.com/u/98196116/screenies/animooted4.gif)

Why is there no release? Because this is just a showing of it so far I have to polish some of the code and make some changes to make it so when compiled with a DCS program you don't have to include the entire DCS font map and other things. (saves a few hundred bytes worth of data!)

So thoughts and suggestions/Things you would like to see?
Title: Re: Text Box System Module - Brass
Post by: Sorunome on March 10, 2014, 10:10:38 am
This is looking pretty awesome so far! Can't wait to see more of it :)
Title: Re: Text Box System Module - Brass
Post by: Matrefeytontias on March 10, 2014, 01:47:59 pm
Looks like a very robust system ! :D I can't stop thinking of an OpenOffice-like program ;D

Suggestions : would it be feasible to have different text sizes ? Embedded images ? Scrolling text for larger-than-screen document viewing ?
Title: Re: Text Box System Module - Brass
Post by: Sorunome on March 10, 2014, 01:52:02 pm
Looks like a very robust system ! :D I can't stop thinking of an OpenOffice-like program ;D
[...]
Erm, there is already DCS's text editor.
Title: Re: Text Box System Module - Brass
Post by: Geekboy1011 on March 10, 2014, 01:56:29 pm
Looks like a very robust system ! :D I can't stop thinking of an OpenOffice-like program ;D

Suggestions : would it be feasible to have different text sizes ? Embedded images ? Scrolling text for larger-than-screen document viewing ?
Text sizes no as its all based off a static font map.  In line images I see no reason why not but is past the scope of what im making(though I plan on editing the font to have basic ascii images for simple art/text maps) .  And anything is possible it's based around a putchar routine so you could technically make it do anything you wanted! I'll have a text stroller demo soon for an rpg. Just didn't get there the other night
Title: Re: Text Box System Module - Brass
Post by: Matrefeytontias on March 10, 2014, 03:53:03 pm
Looks like a very robust system ! :D I can't stop thinking of an OpenOffice-like program ;D
[...]
Erm, there is already DCS's text editor.
Well heh, it requires DCS. I usually don't even have 16384 bytes of free flash.
Title: Re: Text Box System Module - Brass
Post by: Geekboy1011 on March 10, 2014, 04:03:18 pm
Just to make debate. I personally don't see the point of a text editor on calc it's rather pointless when compared to pen and paper.  And is honestly more cumbersome ton work with then anything else. 
Title: Re: Text Box System Module - Brass
Post by: Hayleia on March 10, 2014, 04:14:22 pm
Just to make debate. I personally don't see the point of a text editor on calc it's rather pointless when compared to pen and paper.  And is honestly more cumbersome ton work with then anything else. 
I have two arguments
Now, those arguments can be defeated with the word "phone" for most people but they applied for me last year when my phone was complete crap.

(also, it's "more than", not "more then", "then" is for what comes next, "than" is for comparisons ;))
Title: Re: Text Box System Module - Brass
Post by: willrandship on March 10, 2014, 04:16:22 pm
The biggest reason to have a decent on-calc text editor, I think, is so we can move away from the idea of using the built-in BASIC editor for programming. It's a bad editor for non-tokenized languages. If we had a real text editor then we might even be able to get named functions in an on-calc language.
Title: Re: Text Box System Module - Brass
Post by: Geekboy1011 on March 10, 2014, 07:16:07 pm
The biggest reason to have a decent on-calc text editor, I think, is so we can move away from the idea of using the built-in BASIC editor for programming. It's a bad editor for non-tokenized languages. If we had a real text editor then we might even be able to get named functions in an on-calc language.

I would Rather see a specific app for this then a hacked up text editor that can export tokens. That's just my opinion though. making some code base changes to add a few internal features tonight hopefully it pans out.
Title: Re: Text Box System Module - Brass
Post by: TIfanx1999 on March 10, 2014, 11:28:20 pm
I see this is coming along quite nicely. Good work guys! :D
Title: Re: Text Box System Module - Brass
Post by: Geekboy1011 on March 10, 2014, 11:31:03 pm
(https://dl.dropboxusercontent.com/u/98196116/screenies/animooted7.gif)

Did a little grunt work then made some fancy animations :3
Title: Re: Text Box System Module - Brass
Post by: Sorunome on March 11, 2014, 06:49:32 am
looking awesome :P
Title: Re: Text Box System Module - Brass
Post by: DJ Omnimaga on March 11, 2014, 04:16:08 pm
Looks nice geek! :D

THis reminds me, I should maybe revive the text box engine I had in The Reign of Legends 4ever back in 2004, but use xLIB instead of CODEX and merge it with the text/menu engine in the 2007 incarnation of The Reign of Legends 4. This could be handy for people who makes RPGs.
Title: Re: Text Box System Module - Brass
Post by: Geekboy1011 on March 11, 2014, 04:20:27 pm
Yeah the only problem I am having as of the moment is I need a masked sprite routine for the Corners. I will probably have to rewrite the code for the corners sadly to accommodate. When I designed it at first I did not account for the fact that I need them masked >.<
Title: Re: Text Box System Module - Brass
Post by: chickendude on March 12, 2014, 01:18:52 am
I've got a simple masked sprite routine you can use, though i think it uses SMC.
Title: Re: Text Box System Module - Brass
Post by: Geekboy1011 on March 12, 2014, 01:51:31 pm
I will gladly take a look at it/if it works use it :D
Title: Re: Text Box System Module - Brass
Post by: chickendude on March 15, 2014, 10:33:19 am
OK, here's the first one, it requires the mask to immediately follow the sprite. This one was for an 8x7 cursor i had, so you might want to change the 7s to 8s if you want to draw an 8x8 sprite. Also, my graph buffer had an extra 16x16 column (14 bytes wide), so you might need to adjust some of the width values. For example, the multiplication at the beginning, the ld de,14 for the aligned loop, and the ld de,13 at the ebd if the notAligned loop.
Code: [Select]
;l = y
;a = x
;ix = sprite
putSpriteMasked:
    ld b,7
    ld h,0
    ld e,l
    ld d,h        ;ld de,hl
    add    hl, hl    ;x2
    add    hl, de    ;x3
    add    hl, hl    ;x6
    add    hl, de    ;x7
    add    hl, hl    ;x14

    ld e,a        ;guardar e en a para sacar el offset x
    srl e
    srl e
    srl e        ;/8
    add    hl,de
    ld de,gbuf
    add    hl,de
    ld (cursorGbufLoc),hl
    push hl
    push bc
    ex af,af'
;copy the bytes beneath the cursor
        ld a,b            ;sprite height
        ld de,cursorGbufSave
         ldi            ;load gbuf into gbuf buffer ()
         ldi            ;guardar dos bytes debajo del cursor
         ld bc,12
         add hl,bc        ;próxima fila del gbuf
         dec a
        jr nz,$-9
    ex af,af'
    pop bc
    pop hl
    and $07        ;x offset
    ld c,a
    or a        ;si x offset=0, significa que el sprite está alineado
    jr nz,maskedNotAlignedLoop
        ld de,14
maskedAlignedLoop:
        ld a,(hl)
        and (ix+7)
        xor (ix)
        ld (hl),a        ;guardar
        inc ix            ;próximo byte
        add hl,de         ;próxima fila del gbuf
        djnz maskedAlignedLoop
        ret
maskedNotAlignedLoop:
    push bc            ;b = número de iteraciones restantes, c = xoffset
        ld b,c
        ld a,(ix+7)    ;máscara
        ld c,$FF    ;dummy byte
        ld d,(ix)
        ld e,0
mNARotate:
        scf
        rra            ;a = mask
        rr c        ;c = overflow
        srl d        ;d = sprite byte
        rr e        ;e = sprite overflow
        djnz mNARotate
;mask = ac
;sprite = de
        and (hl)
        xor d
        ld (hl),a    ;primer byte
        inc    hl
        ld a,c
        and (hl)
        xor e
        ld (hl),a    ;segundo byte del sprite
        ld de,13
        add    hl,de    ;próxima fila
        inc ix
    pop    bc
    djnz maskedNotAlignedLoop
    ret

This is a modified 8xY version of that that supports variable height masks and with simple y clipping (only for the bottom, but adding it for the top is really easy) and x boundary detection, ie it won't draw the sprite if a pixel is offscreen.
Code: [Select]
;e = x
;l = y
;a = sprite height
draw_sprite_mask12:
    ld a,12
draw_sprite_mask:
    ld (aligned_mask),a        ;update masks
    ld (unaligned_mask),a    ;masks should be at the end of the sprite (sprite+sprite_height)

    ld d,a
    ld a,e                ;check x
    cp 89
     ret nc

    ld a,l                ;check y offscreen and simple clipping
    or a
     jp p,+_
         neg
         ld c,a
         ld b,0
         add ix,bc
        neg
        add a,d            ;a negative Y + height will tell us the new height (pixels on screen)
        ld d,a            ;save new height (y+height)
        ld l,0            ;set y coord to 0
_    add a,d
    cp 65
     ret nc

    ld a,d
               
    ld h,0
    ld d,h
    ld c,l
    ld b,h                ;ld bc,hl
    add    hl,hl            ; *2
    add    hl,bc            ; *3
    add    hl,hl            ; *6
    add    hl,hl            ;Y*12
    ld b,a                ;sprite height to b
    ld a,e
    srl e
    srl e
    srl e                ;/8
    add    hl,de
    ld de,gbuf
    add    hl,de            ;gbuf + y offset + x offset
    and $07                ;x offset
    ld c,a
    or a                ;if x offset=0, sprite's aligned
     jr nz,maskedNotAlignedLoop
        ld de,12
maskedAlignedLoop:
        ld a,(hl)        ;gbuf byte
aligned_mask = $+2
        and (ix+12)        ;mix the mask
        xor (ix)        ;fill in with the sprite
        ld (hl),a        ;update
        inc ix            ;next byte
        add hl,de         ;next row
        djnz maskedAlignedLoop
        ret
maskedNotAlignedLoop:
    push bc                ;b = iterations left, c = x offset
        ld b,c
unaligned_mask = $+2
        ld a,(ix+12)    ;mask
        ld c,$FF        ;dummy byte
        ld d,(ix)
        ld e,0
mNARotate:
        scf
        rra                ;a = mask
        rr c            ;c = overflow
        srl d            ;d = sprite byte
        rr e            ;e = sprite overflow
        djnz mNARotate
;mask = ac
;sprite = de
        and (hl)        ;mask1 + gbuf1
        xor d            ;sprite1
        ld (hl),a
        inc    hl
        ld a,c
        and (hl)        ;mask2 + gbuf2
        xor e            ;sprite2
        ld (hl),a
        ld de,11
        add    hl,de        ;next row gbuf
        inc ix            ;next row sprite
    pop    bc
    djnz maskedNotAlignedLoop
    ret
EDIT: The second one is for a normal 12-byte width gbuf.
Title: Re: Text Box System Module - Brass
Post by: Geekboy1011 on March 15, 2014, 01:01:33 pm
I shall more then likely use then second one thanks :D clipping is not my problem sooo lol
Title: Re: Text Box System Module - Brass
Post by: chickendude on March 16, 2014, 12:44:57 pm
Well then you can remove the clipping code at the top and save a few bytes :)