OH Man - O - Man, what is the problem?

Started by Amanda Dearheart, July 19, 2024, 04:49:16

Previous topic - Next topic

Amanda Dearheart

Ok, guys I am trying to create a MACRO that has a secondary MACRO embedded within it to display a small rectangular window on screen.  Here is the the macro itself,  the 'print_chr_at' is the embedded macro.
BTW, I am using the CBM Prg Studio to develop the code.  The funny thing is (HA! HA!) when I use the print_chr_at alone, it runs
fine, but when I embed it within WINDOW, I get an error message.  Look at the code below!

; WINDOW  X, Y, WIDTH, HEIGHT, FILLCHAR, FOREGROUND COLOR
;    X , Y         -- Top Left corner of window of where to start drawing
;    WIDTH, HEIGHT -- if the terms were not clear,  how wide and how high is the WINDOW
;    FILLCHAR      --  the character to be drawn, anything from a space to the letter 'z'
;    FOREGROUND COLOR --  you get three guesses!
defm    WINDOW$                                 ; not to be confused with the OS by Microsoft, but the title of our macro
        LDX #$00                                ; initialiae the x and y registers to zero
        LDY #$00
_Loopy  INY                                     ; Start our Row loop, as handled by the Y index register, increment the value in the Y rregister
        CPY /4                                  ; compare the Y rregister with the HEIGHT parameter
        BEQ _Exit                               ; if it is equal than exit our macro
        LDX #$00                                ; reset the X register here again for the second time to 0 so that when we exit X loop
                                                ; it will start over agsin
_Loopx  INX                                     ; do the same for the X register that we did for the Y register
        CPX /3
        PRINT_CHR_AT$ /1 /2 /5 /6               ; and now using s pre-built macro print the character
        BEQ _Loopx                              ; since we compared the x register with our WIDTH parameter already
                                                ; lets loop to finish the current row
        JMP _Loopy                              ; otherwise, lets start a new row
_Exit   RTS                                     ; do I really need to explain this
        endm       





 ... and in case you needed it, the Print_chr_at code!


   PRINT_CHR_AT$                   
        LDA #/4                         ;  set the color of the printable character first
        STA PEN_COLOR                   ;  store it in the pen_color
        LDA #/3                         ;  finally, get the character
        STA $30C                        ;  780  store it in the accumulator storage area
        LDX #/1                         ;  Load the x value
        STX $30D                        ;  781  store it in the .x register
        LDY #/2                         ;  Load the y value
        STY $30E                        ;  782  store it in the .y register
        LDA #$00
        STA $30F                        ;  783  clear the carry flag by storing 0 in the .p register
        JSR $E50A                       ;  58634 jump to the plot routine in the kernal
        JSR CHROUT                      ;  JUMP TO THE KERNAL print routine
        endm


... and now the code from where I call the macros from.  All if fine until I reach the WINDOW call, and then the error is generated



[size=2][font=Courier New, monospace][/font][/size]

        CLEAR_SCREEN$ BLACK
        PRINT_CHR_AT$ #$10, #$20, #$42, WHITE
        PRINT_CHR_AT$ #$10, #$08, #$42, BLUE
        PRINT_CHR_AT$ #$10, #$05, #$42, GREEN
        PRINT_CHR_AT$ #$15, #$20, #$42, RED
       
        ; usage
        ; WINDOW  (x,y), WIDTH, HEIGHT, FILLCHAR, FOREGROUND COLOR
        WINDOW$ #$10, #$15, #$08, #$12, #$42, WHITE[/font][/size][/pre]

... and here is the error message the code generates.
[Error  ] Line 51:Invalid Address Mode "print_chr_at$ #$10 #$15 #$42 white"  -  C:\Documents\Active Proje
cts\Retro Computing\C64\macrotest\mctest\main.asm

As I understand 6502 address modes, The # represents an direct value as opposed to a memory address, The $ represents a hexadecimal value (base 16) the 'white' color constant is defined within a another module with similair #$ syntax.








Prepare to be assimilated !  Resistance is futile!

dawlane

Try removing all hash characters from the MACROs:
E.G.
PRINT_CHR_AT$ #$10, #$20, #$42, WHITE
PRINT_CHR_AT$ $10, $20, $42, WHITE

SToS

As dawlane says, and the reason why is because you already have the # in the macro definition. i.e. #/1 etc..

Amanda Dearheart

Prepare to be assimilated !  Resistance is futile!