Users browsing this thread: 2 Guest(s)
Imp's Mapping (in development)

#1
Posts: 256
Threads: 22
Thanks Received: 105
Thanks Given: 110
Joined: Dec 2018
Reputation: 18
Status
Moog
Serity was helping me work out a graphical mechanics problem... that is, the desire to have Imp status show on the map for the character.

Surprised Kappa!

Here's what I've got so far:
*Works on World Map
*Correctly reverts when Imp status is removed.
*Area Maps will display the wrong palette


I'm personally fine with the last one, but I know others might not be.  As such, I thought I'd share the code here so others could work on it if they so desire.
The world map part is really straight-forward, in the EE bank we simply add a check for Imp status and then change the graphics of the 'map display character' in the RAM accordingly.
The field map part is more complicated.  I've taken parts of the code that sets character graphics on a load, and injected them at a part of the C0 bank that runs more frequently.  I've only done some cursory testing on this, so I'm unsure what its underlying complications might be.
Code:
==================================
Working Version 0_07!  (No Field Palettes)

Imp's Mapping
==================================
C0/BD36:                    D65A
    20 5A D6                JSR $D65A        [Was B9 01 16, LDA $1601,Y]
        
C0/00E5:                    D767
    20 67 D7                JSR $D767        [Was 20 A3 18, JSR $18A3]


C0/D65A:
    B9 14 16                LDA $1614,Y        [Current status of actor]
    89 20                    BIT #$20        [Is Imp bit set?]
    D0 04                    BNE    skipAhead    [Branch if so]
    B9 01 16                LDA $1601,Y        [Load saved character appearance]
    60                        RTS                [Resume normal code]
    A9 0F                    LDA #$0F        [Load the Imp graphic]
    60                        RTS                [Resume normal code]

C0/D767:
    20 A3 18                JSR $18A3        [Execute original code]
    48                        PHA
    5A                        PHY
    DA                        PHX                [Protect variables]
    A6 00                    LDX $00            [What's below recreates some of the draw functions used in a normal load]
    9B                        TXY                
                       [StartLoop]
    20 5A D6                JSR $D65A        [New subroutine that makes an Imp status check]      ***Points to Freespace C0/D65A***
    9D 79 08                STA $0879,X        [Save the result as the character graphic]
        7B                        TDC
        A9 01                    LDA #$01
        C2 21                    REP #$21        [This stuff is math to check if we've checked everybody... I think]
        8A                      TXA
        69 29 00                  ADC #$0029
        AA                      TAX
        98                      TYA
        18                      CLC
        69 25 00                  ADC #$0025
        A8                          TAY
        7B                      TDC
        E2 20                    SEP #$20          [8 bit accum./memory]
        C0 50 02                  CPY #$0250
        D0 E2                    BNE StartLoop       [Loop back to subroutine $D65A based on the result of the previous line]
              [EndLoop]
    FA                        PLX                [Restore original variables]
    7A                        PLY
    68                        PLA
    60                        RTS                [Return to normal code]

EE/033F:
    4C 01 AF                JMP $AF01        [Was BD 01 16, LDA $1601,X]

EE/AF01:
    BD 14 16                LDA $1614,X        [Load status byte 1 of this actor]
    89 20                    BIT #$20        [Check if Imp bit is set]
    F0 0E                    BEQ skipAhead    [Branch if not]
    A9 0F                    LDA #$0F        [Load Imp actor graphic]
    8D FB 11                STA $11FB        [Store in graphics to display for lead character]
    A9 05                    LDA #$00        [Load Imp actor palette]
    8D FC 11                STA $11FC        [Store in palette to display for lead character]
    A6 5A                    LDX $5A
    80 0F                    BRA Exit
    BD 01 16                LDA $1601,X        [Load actor's character graphic]
    8D FB 11                STA $11FB        [Store in graphics to display for lead character]
    A6 5A                    LDX $5A
    BD 70 1F                LDA $1F70,X        [Load current actor's character palette]
    4A                        LSR
    8D FC 11                STA $11FC        [STore in palette to display for lead character]
    4C 4E 03                JMP $034E        [Go back to normal code execution]
EDIT: Forgot attachment.  Note that the spaces used were free in my hack (which uses a slightly older version of the C.V. Reynolds bugfix compilation).  That said, I hope these spaces are unused but I can't guarantee it.  I apologize that the code is not more portable: I've annotated the one line that points to a specific address and would need changing if you need to move the used freespace.


Attached Files
.zip  Imp's Map 0_7 (UH).zip (284 bytes, 1 downloads)
  Find
Quote  
[-] The following 3 users say Thank You to C-Dude for this post:
  • Gi Nattak (01-10-2021), madsiur (01-11-2021), Warrax (01-10-2021)



Messages In This Thread
Imp's Mapping (in development) - by C-Dude - 01-10-2021, 06:52 PM
RE: Imp's Mapping (in development) - by Gi Nattak - 01-10-2021, 09:41 PM
RE: Imp's Mapping (in development) - by C-Dude - 01-10-2021, 09:42 PM

Forum Jump:

Users browsing this thread: 2 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite