Hoping to make your life's design a bit more dynamic!

It is currently Thu Mar 28, 2024 12:41 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
Post subject: Assembly hacking is...
PostPosted: Sun Nov 08, 2009 7:48 pm 
Offline
Site Admin
User avatar

Joined: Fri Oct 09, 2009 4:53 pm
Posts: 875
Location: South Florida
VERY TIME CONSUMING!!! That's especially true when working on games like Chaos Seed and Slayers. In chaos seed, I had to deal with ( and still need to finish ) codind numerous variable width font routines. And the game still screams at Draken due to the lack of Video RAM space allocated per text / menu box. But I trust we will figure something out...

As for Slayers, the menu system had to be rewritten three times so far. ( why no word for 3 like twice for 2 )
Once for compression using DTE. That was scratched. Then added 2 Line support, but was still limited. Then I decided to use a form of compression, redirection and space filling. I feel good about my efforts but I swear if anyone else wanted to handle such a thing they would have NOT liked it!

Hope you all appreciate our efforts in trying to bring out the best we can achieve with these projects. :)

I attached the core of Slayers' Variable Width ROutine source code for your viewing pleasure. Maybe some one can learn from it!

Code:
;###########################################;
; Variable width font routine for Slayers   ;
; The change affects the main dialogue only ;
; Compiled using Byuu's xKas software.      ;
; NOTE: Code inserted Assuming NO HEADER    ;
;###########################################;

;##########################
; Variables that exist    #
;##########################

 !Character    = $FFF0
 !BitsLeft    = $FFF2
 !iFlag       = $FFF4
 !FTable    = $FFDE

 !BkData    = $16

 !iLoop       = $18
 !TextPosi    = $0A,x
 !TilePosi    = $0D,x
 !MapPosi    = $0E,x
 !ScrollTilePosi = $1A,x

 !CharFlag    = $FFDC
 !CharCount    = $1C,x

;##########################
; Variables that exist    #
;##########################


lorom



;###################################################;
;                                                   ;
;                                                   ;
;            Brand new font routine code            ;
;                                                   ;
;                                                   ;
;###################################################;
main() {

   org _NewCodeLocation_
   ;
_RedirectFontRoutine_:
   ; 154 BYTES available for new code
   ;
   ; Assumes: Y = font index
   ;          X = buffer position for storage
   ;           
   rep #$20
   ;
   jsl _CalculateFontIndex_

   ;----------------------
   phb
   lda.w #_FontData_
   sta.b $1A

   sep #$20
   lda.b #$7E
   pha
   plb
   ;----------------------

   lda.b $12,x
   bit.b #$40
   beq _UseClearBackGround_

      ;-------------------
      rep #$20
      lda.w #$0000
      bra _StoreColor_   

   _UseClearBackGround_:
      rep #$20
      lda.w #$FF00

   _StoreColor_:
      sta.b !BkData


;-------------------------;
;                         ;
;-------------------------;
_StandardVWFont_:
   ;-------------------------;
   ; Loop and store the data ;
   ;-------------------------;
   sep #$20
   lda.w !BitsLeft   ; Max pixels per tile is 16
   and.b #$0F   ; Clear all garbage and use only max tile size ALWAYS!
   sta.w !BitsLeft   ; replace the "pixels remaining" variable

   ;--------------------------------------;
   ; Test to see if buffer needs clearing ;
   ;--------------------------------------;
   lda.w !BitsLeft+1      ; Test this first because it is set
   bne _ClearBuffer_      ; when we need to shift data to the left!

   lda.w !BitsLeft         ; If pixels are left on a tile, do not clear
   bne _NoBufferClear_      ; the existing tile data
   ;---------------

   _ClearBuffer_:      
      jsl _ClearTheBuffer_
   ;-------------------


_NoBufferClear_:
   ;
   rep #$20
   ldx #$0010
   stx.b !iLoop
   ldx.w #$0000
   ;-------------------

   _StoreTopAndBottom_:
      rep #$20
      lda [$1A],y
      xba
      iny
      iny
      ;---------------

      phx
      ;---------------

      ldx !BitsLeft+1
      bne _ShiftCodeLeft_
      ;---------------


      _ShiftCodeRight_:
         ;
         jsl _ShiftBitsRight_   ; This will shift the character according 
         bra _DidRightShift_   ; to pixels remaining on the current tile

         ;---------------
      _ShiftCodeLeft_:
         ;
         jsl _ShiftBitsLeft_   ; This will shift the character according
                  ; to pixels left


         ;----------------------;
         ;                      ;
         ;----------------------;
         _DidRightShift_:
            sep #$20
            plx      ; Get X back      
   
            ; Transfer the adjusted font data to the transfer buffer
            ;
            jsl _StoreFont_
            inx
            inx

      cpx.w #$0010
      bne _NoAddYet_
      ;------------------
      
      rep #$20
      txa
      clc
      adc.w #$0010
      tax
      sep #$20
      ;------------------

_NoAddYet_:
;---------------
   dec !iLoop
   bne _StoreTopAndBottom_
   
   rep #$20
   jmp _FinishProcessingText_



;#######################################################;
;                                                       ;
; Location of Most font code, New font and Width table  ;
;                                                       ;
;#######################################################;
   org _LocationForCodeProcessing_
   ;   
;#################;
; Fix pixels left ;
;#################;
_FixPixelsLeft_:
   ; If tile was shifted left give a new BitsLeft
   php
   phb
   ;---------------
   sep #$20
   lda.b #$7E
   pha
   plb

   ;--------------
   lda.w !BitsLeft+1
   beq _SetBitsLeft_

   ;--------------
   rep #$20
   lda.w #$0000   
   sta.w !BitsLeft+1      ; Clear the Left shift flag
   ;--------------

   lda.w $161F
   sec
   sbc.w #$0020   

   inc.w !iFlag
   ;--------------

   plb
   plp
rtl


;-----------------;
; Set pixels left ;
;-----------------;
_SetBitsLeft_:
   lda.w !BitsLeft
   bne _PixelsLeftOnTile_
   ;---------------

   lda.b #$10
   ldx.w !Character
   sec
   sbc.l _FontWids_,x
   beq _UniversalEnd_
   ;-----------------

_MultiPurpose_:
   sta.w !BitsLeft
   ;--------------
   rep #$20
   lda.w $161F
   sec
   sbc.w #$0020

   inc.w !iFlag
   ;--------------

   plb
   plp
rtl   

;---------------------;
;                     ;
;---------------------;   
_PixelsLeftOnTile_:
   ; Assumes: Accum = Bits left
   ;
   ldx.w !Character
   sec
   sbc.l _FontWids_,x
   bmi _BitsOverFlowed_
   beq _UniversalEnd_
   bra _MultiPurpose_
   
;---------------------;
;                     ;
;---------------------;   
_BitsOverFlowed_:
   ; Calculate what the new pixels left will
   ; be for the NEW tile!
   ;
   eor.b #$FF
   inc
   ;--------------

   ldx.w !BitsLeft
   stx.w !BitsLeft+1   ; We want to do a LEFT shift
            ; with THIS amount next time
   ;--------------
   sta.w !BitsLeft   
   lda.b #$10
   sec
   sbc.w !BitsLeft

   ;--------------
   rep #$20
   ldx.b $64
   dec !TextPosi   ; Go back and get the same character
         ; but do a LEFT shift instead!
   sep #$20

;---------------------;
; Go to Universal End ;
;---------------------;   
_UniversalEnd_:
   sta.w !BitsLeft
   ;--------------
   rep #$20
   lda.w $161F

   plb
   plp
rtl   
   



;##############################################;
;                                              ;
;          Right Bit Shifting Code             ;
;                                              ;
;##############################################;
_ShiftBitsRight_:           
   ;
   ; Assumes X = Index to Shift Table
   ;
   php
   phx   
   rep #$20

   pha
   lda !BitsLeft
   and.w #$000F
   bne _ShiftTheData_

   ;------------------
   pla
   bra _NoShift_

   ;------------------
   _ShiftTheData_:
      dec
      asl
      tax
      pla
      jmp (_RShifter_,X)

_RShifter_:
   dw _R1,_R2,_R3,_R4,_R5,_R6,_R7,_R8,_R9,_RA,_RB,_RC,_RD,_RE,_RF

;##########################;
; Shift bits to the right  ;
;##########################;
_R1:
   LSR
_R2:
   LSR
_R3:
   LSR
_R4:
   LSR
_R5:
   LSR
_R6:
   LSR
_R7:
   LSR
_R8:
   LSR
_R9:
   LSR
_RA:
   LSR
_RB:
   LSR
_RC:
   LSR
_RD:
   LSR
_RE:
   LSR
_RF:
   LSR

;------------;
_NoShift_:
   plx
   plp
rtl


;##############################################;
;                                              ;
;           Left Bit Shifting Code             ;
;                                              ;
;##############################################;
_ShiftBitsLeft_:
   ;
   ; Assumes X = Index to Shift Table
   ;
   php
   phx   
   rep #$20

   pha
   lda.w !BitsLeft+1
   and.w #$000F

   ;------------------
   _LeftShiftTheData_:
      dec
      asl
      tax
      pla
      jmp (_LShifter_,X)

_LShifter_:
   dw _LF,_LE,_LD,_LC,_LB,_LA,_L9,_L8,_L7,_L6,_L5,_L4,_L3,_L2,_L1


;--------------------;
; Left shifting code ;
;--------------------;
_L1:
   ASL
_L2:
   ASL
_L3:
   ASL
_L4:
   ASL
_L5:
   ASL
_L6:
   ASL
_L7:
   ASL
_L8:
   ASL
_L9:
   ASL
_LA:
   ASL
_LB:
   ASL
_LC:
   ASL
_LD:
   ASL
_LE:
   ASL
_LF:
   ASL

  ;------------;
_NoLShift_:
   plx
   plp
rtl


;##########################;
;                          ;
;##########################;
_StoreFont_:
   ;
   php
   rep #$20
   pha
   ;----------------

   and.w #$00FF
   ora.l $7E2810,x   ; Right side
   ora.b !BkData
   sta.l $7E2810,x   ; Right side

   pla
   xba
   and.w #$00FF
   ora.l $7E2800,x   ; Right side
   ora.b !BkData
   sta.l $7E2800,x   ; Left side

   ;----------------
   plp
rtl



;##########################;
;                          ;
;##########################;
_ClearTheBuffer_:
   php
   phb
   phy
   phx
   ;---------------      

   rep #$20
   lda.b !BkData
   sta.l $7E2800
   ldx.w #$2800
   ldy.w #$2802
   lda.w #$003D
   mvn $7E7E
   ;---------------

   plx
   ply
   plb
   plp
rtl



;##########################;
;                          ;
;##########################;
_CalculateFontIndex_:
   pha
   ;
   clc
   adc !FTable+$7E0000
   sta !Character+$7E0000      ; How we access a different font table's width data

   ;----------------------
   ; Shift for NEW 16x16 font
   lda !FTable+$7E0000      ; Accessing a different font table??
   rep 4 : asl         ; left shift 4 times
   pha
   ;
   lda $03,s
   asl
   asl
   asl
   asl
   asl
   clc
   adc $01,s
   tay
   pla
   pla
rtl


;-------------------------------;
; Where the font data is stored ;
;-------------------------------;
_FontData_:
   ; Font file found here

_FontWids_:
   ; Width file found here
}


Last edited by Bongo` on Mon Nov 09, 2009 11:17 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
Post subject: Re: Assembly hacking is...
PostPosted: Sun Nov 08, 2009 10:53 pm 
Offline
User avatar

Joined: Tue Oct 20, 2009 11:37 pm
Posts: 443
There is no doubt that thousands of people have benefited from the work you and others in DD have done to bring games to English speakers. There doesn't appear to be many people that can match your talents and skills in this area either considering what you have done with games like Mystic Ark and Lennus 2. Thanks again for all your efforts and I hope you gain great satisfaction from it.


Winston Churchill in response to forming an alliance with the Soviet Union during World War 2:
If Hitler invaded Hell I would make at least a favorable reference to the devil in the House of Commons


Top
 Profile  
Reply with quote  
Post subject: Re: Assembly hacking is...
PostPosted: Mon Nov 09, 2009 4:07 am 
Offline
User avatar

Joined: Tue Oct 20, 2009 6:55 pm
Posts: 844
Wow Bongo' that's some massive coding there, your talents are indeed priceless my friend
and your hacking skills are just as great as your character, so you got it all.
Go go Bongo' haha.


Top
 Profile  
Reply with quote  
Post subject: Re: Assembly hacking is...
PostPosted: Mon Nov 09, 2009 5:13 am 
Offline
Site Admin
User avatar

Joined: Fri Oct 09, 2009 11:54 pm
Posts: 2340
Location: Virginia
...fruitful. I posted some of the result's of Bongo`'s latest menu work on the main page. You should have seen the mess they were in with just the raw inserts, before he sent me the updated files. Of course, it's worth the effort. It gives the structures of these games a professional appearance. That forces me to take my time and try to craft a good story to match. So, Bongo`, why don't you relax for a few days? You've earned it! This menu work he just did seemed to put us over that proverbial hump with Slayers, the point at which the rest of the way should feel increasingly downhill, at least for fleshing out the story.

Image Image
Image Image


Image


Top
 Profile  
Reply with quote  
Post subject: Re: Assembly hacking is...
PostPosted: Mon Nov 09, 2009 5:14 am 
Offline
Site Admin
User avatar

Joined: Tue Oct 20, 2009 3:58 pm
Posts: 1276
Location: Korea
Poor Bongo` has to deal with a lot of work. I'm constantly asking him to fix things with Chaos Seed because there are still a lot of things that need to be sorted out. We really should be careful how much workload we send his way. I'm all for helping other groups out, but it seems like he has less and less time to do "our" projects.

Anyways... I like that code Bongo`! Sharing with the community is always a good idea. :)


Top
 Profile  
Reply with quote  
Post subject: Re: Assembly hacking is...
PostPosted: Mon Nov 09, 2009 6:12 am 
Offline
Site Admin
User avatar

Joined: Mon Oct 05, 2009 9:49 am
Posts: 1381
Location: Oklahoma City
Yeah, I'm delaying sending him anything from Hourai for now so he can focus on other things (and trying to find ways around as many of them as I can to only limited success). However, I'm not so sure I can delay them all much longer. In fact, I guess I should really send him a message now because a certain hack was left unfinished (due to changes in approach) that I really need his help dealing with.


Image


Top
 Profile  
Reply with quote  
Post subject: Re: Assembly hacking is...
PostPosted: Mon Nov 09, 2009 11:31 pm 
Offline
Site Admin
User avatar

Joined: Fri Oct 09, 2009 4:53 pm
Posts: 875
Location: South Florida
taskforce wrote:
Yeah, I'm delaying sending him anything from Hourai for now so he can focus on other things (and trying to find ways around as many of them as I can to only limited success). However, I'm not so sure I can delay them all much longer. In fact, I guess I should really send him a message now because a certain hack was left unfinished (due to changes in approach) that I really need his help dealing with.


Taskforce... Believe it or not, but working on slayers has given me an idea or two that can help on Horai. I have to write down what I mean and present it to you. I had the idea when you asked about the $0C code for the menu text... Well, I have a few ideas and they can be efficient at that too! :)


Last edited by Bongo` on Tue Nov 10, 2009 3:19 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
Post subject: Re: Assembly hacking is...
PostPosted: Tue Nov 10, 2009 2:48 pm 
Offline
Site Admin
User avatar

Joined: Mon Oct 05, 2009 9:49 am
Posts: 1381
Location: Oklahoma City
Bongo` wrote:
taskforce wrote:
Yeah, I'm delaying sending him anything from Hourai for now so he can focus on other things (and trying to find ways around as many of them as I can to only limited success). However, I'm not so sure I can delay them all much longer. In fact, I guess I should really send him a message now because a certain hack was left unfinished (due to changes in approach) that I really need his help dealing with.


Taskforce... Believe it or not, but working on slayers has given me an idea or two that can help on Horai. I have to write down what I mean and present it to you. I had the idea when you asked about the $0C code for the menu text... Well, I have a few ideas and they can be efficient at that too! :)


Cool. Can't wait to here your ideas. Anything that makes my life easier or this game better, and you know I'm all ears :)


Image


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group