base:petscii_to_screencode
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | base:petscii_to_screencode [2015-04-17 04:33] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== PETSCII to screencode conversion ====== | ||
+ | By Mace | ||
+ | |||
+ | While creating my own routine to display a floppy directory, I stumbled accross the awkward difference between ASCII/ | ||
+ | An easy way of converting would be to create a table, but that takes quite some space for something that is not that hard to code. | ||
+ | Simply said, you have to divide the *SCII code in blocks and for each block apply a certain calculation to get the screencode. | ||
+ | |||
+ | It could look something like this: | ||
+ | < | ||
+ | |||
+ | cmp #$20 // if A<32 then... | ||
+ | bcc ddRev | ||
+ | |||
+ | cmp #$60 // if A<96 then... | ||
+ | bcc dd1 | ||
+ | |||
+ | cmp #$80 // if A<128 then... | ||
+ | bcc dd2 | ||
+ | |||
+ | cmp #$a0 // if A<160 then... | ||
+ | bcc dd3 | ||
+ | |||
+ | cmp #$c0 // if A<192 then... | ||
+ | bcc dd4 | ||
+ | |||
+ | cmp #$ff // if A<255 then... | ||
+ | bcc ddRev | ||
+ | |||
+ | lda #$7e // A=255, then A=126 | ||
+ | bne ddEnd | ||
+ | |||
+ | dd2: and #$5f // if A=96..127 then strip bits 5 and 7 | ||
+ | bne ddEnd | ||
+ | |||
+ | dd3: ora #$40 // if A=128..159, then set bit 6 | ||
+ | bne ddEnd | ||
+ | |||
+ | dd4: eor #$c0 // if A=160..191 then flip bits 6 and 7 | ||
+ | bne ddEnd | ||
+ | |||
+ | dd1: and #$3f // if A=32..95 then strip bits 6 and 7 | ||
+ | bpl ddEnd // <- you could also do .byte $0c here | ||
+ | |||
+ | ddRev: eor #$80 // flip bit 7 (reverse on when off and vice versa) | ||
+ | ddEnd: | ||
+ | // screencode is now in accu | ||
+ | </ | ||
+ | |||
+ | If you would like to use a table after all, you could use this one: | ||
+ | < | ||
+ | tab_petscii2screencode: | ||
+ | ; | ||
+ | .byte $80, | ||
+ | .byte $90, | ||
+ | .byte $20, | ||
+ | | ||
+ | .byte $00, | ||
+ | | ||
+ | .byte $40, | ||
+ | | ||
+ | .byte $c0, | ||
+ | | ||
+ | .byte $60, | ||
+ | | ||
+ | .byte $00, | ||
+ | | ||
+ | .byte $60, | ||
+ | | ||
+ | </ |
base/petscii_to_screencode.txt · Last modified: 2015-04-17 04:33 by 127.0.0.1