(새 문서: 게임보이用 UTF-8 디코딩 函數. 出力은 레지스터 c, d, e에 UTF-32로 디코딩되어 나온다. 맨밑의 <code>@nextByte</code>는 다음 臺詞 바이트를 가져오는 役割을 하며, 게임마다 따로 具顯하여야 한다. <pre> ; @param b: Bank number to read from ; @param hl: Start address to read from ; @return c: Unicode codepoint, upper 1 byte ; @return de: Unicode codepoint, lower 2 bytes decodeUTF8: ld c, $00 ld d, $00...) |
잔글 (十八子님이 UTF-8/게임보이 문서를 넘겨주기를 만들지 않고 UTF-8/게임보이/wla-dx 문서로 이동했습니다) |
(차이 없음)
| |
2024년 3월 25일 (월) 00:45 기준 최신판
게임보이
맨밑의 @nextByte는 다음
; @param b: Bank number to read from
; @param hl: Start address to read from
; @return c: Unicode codepoint, upper 1 byte
; @return de: Unicode codepoint, lower 2 bytes
decodeUTF8:
ld c, $00
ld d, $00
call @nextByte
bit 7, a
jr z, @singleByte
bit 5, a
jr z, @doubleByte
bit 4, a
jr z, @tripleByte
bit 3, a
jr z, @quadByte
jr @end
@singleByte:
and a, $7f
ld e, a
jr @end
@doubleByte:
push af
and a, $1c
rrca
rrca
ld d, a
jr @lastByte
@tripleByte:
and a, $0f
rlca
rlca
rlca
rlca
ld d, a
call @nextByte
push af
and a, $3c
rrca
rrca
or d
ld d, a
jr @lastByte
@quadByte:
and a, $07
rlca
rlca
ld c, a
call @nextByte
push af
and a, $30
rrca
rrca
rrca
rrca
or c
ld c, a
pop af
and a, $0f
rlca
rlca
rlca
rlca
ld d, a
call @nextByte
push af
and a, $3c
rrca
rrca
or d
ld d, a
jr @lastByte
@lastByte:
pop af
and a, $03
rrca
rrca
ld e, a
call @nextByte
and a, $3f
or e
ld e, a
@end:
ret
;; Read next byte from hl, incrementing hl itself
@nextByte:
ld a, :@nextByte
call readByteFromBankAndReturn
inc hl
ret