Can I force ca65 to error if a charmap character is not mapped?

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
MenhirMike
Posts: 4
Joined: Mon Jul 24, 2023 6:07 pm

Can I force ca65 to error if a charmap character is not mapped?

Post by MenhirMike »

So, let's say I have a charmap mapping like this:

Code: Select all

.charmap $30, $00 ; 0
.charmap $32, $02 ; 2
And I then write code like this:

Code: Select all

ldy #'0'
sty PPUDATA
ldy #'1'
sty PPUDATA
ldy #'2'
sty PPUDATA
This will cause ca65 to emit assembly like this:

Code: Select all

8331  A0 00          LDY #$00
8333  8C 07 20       STY PpuData_2007
8336  A0 31          LDY #$31
8338  8C 07 20       STY PpuData_2007
833B  A0 02          LDY #$02
833D  8C 07 20       STY PpuData_2007
So for '1' it uses the ASCII code for the number 1. But what I would really like it to do is to throw a compilation error.

I tried .feature force_range, but that doesn't do anything (because it seems unrelated to charmaps and just be generally about restricting what goes into a .byte?).

So, I wonder if there's a way to tell ca65 to forget everything about ASCII and require every character to be charmapped?
Post Reply