Python Rom simple text editor

205 views Asked by At
def charToByte(c):
    elif c == '<END>':
        return 0x00
    elif c == '<LINE>':
        return 0x01
    elif c == '<WAIT>':
        return 0x03
    elif c == 'aps t':
        return 0x88
    elif c == 'aps s':
        return 0x89
    elif c == 's aps':
        return 0x8A
    elif c == '*':
        return 0x8B
    elif c == 'll':
        return 0x8C
    elif c == 'il':
        return 0x8D
    elif c == 'li':
        return 0x8E
    elif c == ' ':
        return 0xA0
    elif c == '!':
        return 0xA1
    elif c == '?':
        return 0xA2
    elif c == '_':
        return 0xA3
    elif c == '$':
        return 0xA4
    elif c == '"':
        return 0xA6
    elif c == 'aps':

Code so far. I wonder is this correct? Cause I want a character/word to be a rom-specific byte. Example:

Apple = C1 F0 F0 EC E5 . rom-specific byte to c/word. C1 F0 F0 EC E5 = Apple

Rom-specifific Bytes from EBZero. And will have a command-line gui (for now).

Example:

Line 1: TEST LINE
Binary: D4 E5 F3 F4  CC E9 EE E5
User-change: change to whatever.

I'll worry about GUI and Tables later. Modify code from: https://github.com/kiij/CoilSnake

Research is still ongoing.

1

There are 1 answers

0
Steve Barnes On

Instead of a huge if tree just dictionaries, you can then have a dictionary of dictionaries for which ROM or you can load from a file.

It is much easier to read and maintain a dictionary than a huge if tree and will run much faster as well.

AppleRomTable = {'<END>':0x00, '<LINE>':0x01, ....}

char_to_byte(c):
   """ Returns FF for unknown """
   return AppleRomTable.get(c, 0xff)