I'm trying to unify the mod so it's almost the same for all, same code, same areas, except few specific bootloader addresses.
Someone with U1273A(X) - and able to unbrick something goes wrong - please try this!
- Display init: sub_7f60:
sub_7f60:
call !sub_0994 ;7f60 9a 94 09 <<<--- Call original function
movw ax,#0x00a1 ;7f63 10 a1 00 <<<--- Segment remap cmd (Y-mirror)
call !sub_05d1 ;7f66 9a d1 05 <<<--- Send cmd
movw ax,#0x00c0 ;7f69 10 c0 00 <<<--- Scan direction cmd (X-mirror)
call !sub_05d1 ;7f6c 9a d1 05 <<<--- Send cmd
ret ;7f6f af <<<--- Return
- Set position: sub_7f70:
sub_7f70:
push hl ;7f70 b7 <<<--- Same as original function
push ax ;7f71 b1
movw ax,sp ;7f72 89 1c
movw hl,ax ;7f74 d6
mov a,[hl] ;7f75 87
xch a,x ;7f76 30
mov a,[hl+0x06] ;7f77 ae 06
movw hl,ax ;7f79 d6
mov a,#0xb0 ;7f7a a1 b0 <<<--- Row cmd
or a,l ;7f7c 61 6e
mov x,#0x00 ;7f7e a0 00
xch a,x ;7f80 30
call !sub_05d1 ;7f81 9a 68 0A <<<--- Send cmd
mov a,h ;7f84 67 <<<--- Move column value to reg A
cmp a,!mem_7f8e ;7f85 48 8e 7f <<<--- Compare with subtract value at 0x7f8e
bnc lab_7f8d ;7f88 9d 03 <<<--- If carry set,
mov a,!mem_7f8e ;7f8a 8e 8e 7f <<<--- Load A with subtract value at 0x7f8e so it becomes 0 when subtracting
lab_7f8d:
sub a,#0x02 ;7f8d 1d 02 <<<--- Subtract 2 to column value
mov h,a ;7f8f 77 <<<--- Update H reg for later use in lower column cmd
and a,#0x0f ;7f90 5d 0f <<<--- Isolate lower column data
mov x,#0x00 ;7f92 a0 00
xch a,x ;7f94 30
call !sub_05d1 ;7f95 9a 68 0A <<<--- Send cmd
mov a,h ;7f98 67 <<<--- Move column value to reg A
ror a,1 ;7f99 24 <<<--- Rotate 4 bits to the left to get higher column bits
ror a,1 ;7f9a 24
ror a,1 ;7f9b 24
ror a,1 ;7f9c 24
and a,#0x0f ;7f9d 5d 0f <<<--- Isolate higher column data
or a,#0x10 ;7f9f 6d 10 <<<--- High column cmd
mov x,#0x00 ;7fa1 a0 00
xch a,x ;7fa3 30
call !sub_05d1 ;7fa4 9a 68 0A <<<--- Send cmd
pop ax ;7fa7 b0
pop hl ;7fa8 b6
ret ;7fa9 af <<<--- Done, return
- Drawing: sub_7faa:
sub_7faa:
push hl ;7faa b7 <<<--- Same as original function
push ax ;7fab b1
push ax ;7fac b1
movw ax,sp ;7fad 89 1c
movw hl,ax ;7faf d6
mov a,[hl+0x0a] ;7fb0 ae 0a
inc a ;7fb2 41
mov [hl+0x0a],a ;7fb3 be 0a
mov x,#0x00 ;7fb5 a0 00
xch a,x ;7fb7 30
push ax ;7fb8 b1
mov a,[hl+0x08] ;7fb9 ae 08
mov x,#0x00 ;7fbb a0 00
xch a,x ;7fbd 30
call !sub_7f70 ;7fbe 9a 70 7f <<<--- Call new oled position function
br !lab_0ad9 ;7fc1 9b d9 0a <<<--- Continue in original function
Hex bytes:
9A 94 09 10 A1 00 9A 68 0A 10 C0 00 9A 68 0A AF B7 B1 89 1C D6 87 30 AE 06 D6 A1 B0 61 6E A0 00 30 9A 68 0A 67 48 8E 7F 9D 03 8E 8E 7F 1D 02 77 5D 0F A0 00 30 9A 68 0A 67 24 24 24 24 5D 0F 6D 10 A0 00 30 9A 68 0A B0 B6 AF B7 B1 B1 89 1C D6 AE 0A 41 BE 0A A0 00 30 B1 AE 08 A0 00 30 9A 70 7F 9B D9 0A
Because the entire firmware can't be disassembled, a manual pattern search and replace was performed:
- INIT: "9A 94 09" (call !sub_0994) -> "9A 60 7F" (call !sub_7f60)
- POSITION: "9A 20 0B" (call !sub_0b20) -> "9A 70 7F" (call !sub_7f70)
- DRAW: "9A C2 0A" (call !sub_0ac2) -> "9A AA 7F" (call !sub_7faa)
Patching offsets: ( .AG file in updater format, not reversed)
Address Value Function
0x18095 0x0C / 0x8C X-mirror off / on
0x1809B 0x0A / 0x1A Y-mirror off / on
0x18071 0x00-0xFF X-offset subtract value, nibble-swapped, so 0x00 / 0x10 / 0x20 for 0/-1/-2 pixel offset (Subtracted to the default 2 offset)
If for whatever reason, instead subtracting you want to increase the column address, patch as following:
0x18072 Replace [D1 F7 E8 E8 30 D9 F7 E8 84] with [D0 00 00 00 00 00 00 00 00].
Address Value Function
0x18071 0x00-0xFF X-offset add value, nibble-swapped, so 0x00 / 0x10 / 0x20 for 0/+1/+2 pixel offset (Added to the default 2 offset)