Advertisement
Zeda

putfs

Dec 5th, 2020 (edited)
2,429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PutFS:
  2. ; read the font from flash to RAM
  3. ; need to add 3*A to the fontpointer
  4.   ld hl,(FontPointer)
  5.   ld b,0
  6.   ld c,a
  7.   add hl,bc
  8.   add hl,bc
  9.   adc hl,bc     ;add hl,bc won't set the right flags, so use adc
  10.   ld a,(font_ptr_page)
  11.   jp p,+_
  12.   or a
  13.   jr z,+_
  14.   set 6,h
  15.   res 7,h
  16.   inc a
  17. _:
  18.   ld c,3
  19.   ld de,$8005
  20.   call readarc
  21.  
  22. ; get the text position and update it
  23.   ld hl,(textRow)
  24. ;  ld b,0 ;B is already 0 from the ReadArc routine
  25.   ld a,h
  26.   cp 24
  27.   ld a,l
  28.   jr c,+_
  29.   ld h,b
  30.   add a,6
  31. _:
  32.   cp 3Bh
  33.   jr c,+_
  34.   sub 3Ch
  35.   jr nc,+_
  36.   add a,6
  37. _:
  38.   ld l,a
  39. ; need to advance the x-coord by 1
  40.   inc h
  41.   ld (textRow),hl
  42.   dec h
  43.   ;want A*12+H/2+(gbuf_temp), and we know A < 64
  44.   add a,a
  45.   add a,a
  46.   ;now A*3+(gbuf_temp)+H/2
  47.   ld c,a
  48.   ld a,h
  49.   ld hl,(gbuf_temp)
  50.   add hl,bc
  51.   add hl,bc
  52.   add hl,bc
  53.   ld c,a
  54.   srl c
  55.   add hl,bc
  56.   rra
  57.   ld e,4    ; now DE points to the byte before the char data
  58.   jr nc,put_left
  59. put_right:
  60.   ld c,$0F
  61.   call put_right2
  62.   call put_right2
  63. put_right2:
  64. ; read in the byte
  65.   inc de
  66.   ld a,(de)
  67.  
  68. ; check if it needs to be inverted
  69.   bit InvertTextFlag,(iy+UserFlags)
  70.   jr z,$+3
  71.   cpl
  72.   ld b,a      ; back up the byte
  73.   call shift_put_lr
  74.   ld a,b      ;restore the byte
  75.   jr put_lr
  76.  
  77. put_left:
  78.   ld c,$F0
  79.   call put_left2
  80.   call put_left2
  81. put_left2:
  82. ; read in the byte
  83.   inc de
  84.   ld a,(de)
  85.  
  86. ; check if it needs to be inverted
  87.   bit InvertTextFlag,(iy+UserFlags)
  88.   jr z,$+3
  89.   cpl
  90.  
  91.   ld b,a      ; back up the byte
  92.   call put_lr
  93.   ld a,b      ;restore the byte
  94.  
  95. shift_put_lr:
  96. ; rotate the nibbles
  97.   rrca
  98.   rrca
  99.   rrca
  100.   rrca
  101. put_lr:
  102. ; mask the byte
  103.   and c
  104.  
  105. ; OR it to the screen
  106.   or (hl)
  107.   ld (hl),a
  108.  
  109. ; advance the gbuf ptr
  110.   ld a,l
  111.   add a,12
  112.   ld l,a
  113.   ret nc
  114.   inc h
  115.   ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement