comparison code_part1/OSTC_code_asm_part1/aa_wordprocessor.asm @ 142:8b75ba28d641

Screen-flipping custom function. - Fix bank safe addressings.
author JeanDo
date Fri, 07 Jan 2011 03:01:02 +0100
parents 6a94f96e9cea
children cb055a7d75f3
comparison
equal deleted inserted replaced
141:622da16b768f 142:8b75ba28d641
57 aa_flags ; Various flags for aa_wordprocessor 57 aa_flags ; Various flags for aa_wordprocessor
58 aa_width:2 ; Width in pixels (0..319) 58 aa_width:2 ; Width in pixels (0..319)
59 aa_bitlen ; Count of pixels when decoding bitmaps. 59 aa_bitlen ; Count of pixels when decoding bitmaps.
60 aa_start:2 ; PROM ptr to start of encoded bitmap 60 aa_start:2 ; PROM ptr to start of encoded bitmap
61 aa_end:2 ; and end of it. 61 aa_end:2 ; and end of it.
62 aa_colorDiv:2 ; Current color, divided by 2 or 4 62 aa_temp:2 ; Current color, divided by 2 or 4
63 ENDC 63 ENDC
64 64
65 ; Flags allocation: 65 ; Flags allocation:
66 #define aa_antialias aa_flags,0 66 #define aa_antialias aa_flags,0
67 #define aa_color_quart aa_flags,1 67 #define aa_color_quart aa_flags,1
249 rcall aa_char_setup ; setup aa_start / aa_end 249 rcall aa_char_setup ; setup aa_start / aa_end
250 rcall aa_char_width ; sum-up width into aa_width 250 rcall aa_char_width ; sum-up width into aa_width
251 bra aa_string_width_1 ; and loop. 251 bra aa_string_width_1 ; and loop.
252 252
253 aa_string_width99: 253 aa_string_width99:
254 return
255
256 ;------------------------------------------------------------------------------
257 ; Fast macros to write to OLED display.
258 ; Adding a call/return adds 3 words and a pipeline flush, hence make it
259 ; nearly twice slower...
260 ;
261 ; Input : commande as macro parameter.
262 ; Output : NONE
263 ; Trash : WREG
264 ;
265 AA_CMD_WRITE macro cmd
266 movlw cmd
267 rcall PLED_CmdWrite
268 ; bcf oled_rs ; Cmd mode
269 ; movwf PORTD,A
270 ; bcf oled_rw ; Tick the clock
271 ; bsf oled_rw
272 endm
273 ;
274 ; Input : PRODH:L as 16bits data.
275 ; Output : NONE
276 ; Trash : NONE
277 ;
278 AA_DATA_WRITE_PROD macro
279 rcall PLED_DataWrite_PROD
280 ; bsf oled_rs ; Data mode
281 ; movff PRODH,PORTD ; NOTE: OLED is BIGENDIAN!
282 ; bcf oled_rw ; Tick the clock
283 ; bsf oled_rw
284 ; movff PRODL,PORTD
285 ; bcf oled_rw ; Tick the clock
286 ; bsf oled_rw
287 endm
288
289 ;------------------------------------------------------------------------------
290 ; Output OLED Window Address commands.
291 ; Inputs : win_top, win_leftx2, win_height, aa_width.
292 ; Output : PortD commands.
293 ; Trashed: PROD
294 ;
295 aa_box_cmd:
296 movf win_leftx2,W,BANKED ; Compute left = 2*leftx2
297 mullw 2
298 AA_CMD_WRITE 0x35 ; this is the left border
299 AA_DATA_WRITE_PROD
300
301 movf aa_width+0,W,ACCESS ; right = left + width - 1
302 addwf PRODL,F,A
303 movf aa_width+1,W,ACCESS
304 addwfc PRODH,F,A
305 decf PRODL,F,A ; decrement result
306 bc aa_box_cmd_1 ; No borrow (/Carry) ? skip propagating.
307 decf PRODH,F,A
308 aa_box_cmd_1:
309 AA_CMD_WRITE 0x36 ; Write and the right border
310 AA_DATA_WRITE_PROD
311
312 movf win_top,W,BANKED ; Write top / bottom window
313 movwf PRODH,A ; (remember PRODH output first)
314 addwf win_height,W,BANKED
315 decf WREG,A
316 movwf PRODL,A ; And PRODL is later...
317 AA_CMD_WRITE 0x37
318 AA_DATA_WRITE_PROD
319
320 movf win_top,W,BANKED ; Start ptr top
321 mullw 1 ; Load into PRODH:L
322 AA_CMD_WRITE 0x20
323 AA_DATA_WRITE_PROD
324
325 movf win_leftx2,W,BANKED ; Start ptr left
326 mullw 2
327 AA_CMD_WRITE 0x21
328 AA_DATA_WRITE_PROD
329
330 return 254 return
331 255
332 ;------------------------------------------------------------------------------ 256 ;------------------------------------------------------------------------------
333 ; Decode a compressed char. 257 ; Decode a compressed char.
334 ; Inputs aa_start, aa_end, win_height, win_invert, win_color1, win_color2 258 ; Inputs aa_start, aa_end, win_height, win_invert, win_color1, win_color2
394 318
395 ;---- 2 bit x RGB(16bits) computation -------------------------------- 319 ;---- 2 bit x RGB(16bits) computation --------------------------------
396 clrf PRODL ; We will accumulate result here... 320 clrf PRODL ; We will accumulate result here...
397 clrf PRODH 321 clrf PRODH
398 322
399 ; Take color div 2 into aa_colorDiv. Max red = 15/31 323 ; Take color div 2 into aa_temp. Max red = 15/31
400 rrcf win_color1,W,BANKED ; xRRRRxGG 324 rrcf win_color1,W,BANKED ; xRRRRxGG
401 andlw b'01111011' ; 0RRRR0GG (don't change C) 325 andlw b'01111011' ; 0RRRR0GG (don't change C)
402 movwf aa_colorDiv+0,ACCESS 326 movwf aa_temp+0,ACCESS
403 rrcf win_color2,W,BANKED ; GGGxBBBB 327 rrcf win_color2,W,BANKED ; GGGxBBBB
404 andlw b'11101111' ; GGG0BBBB 328 andlw b'11101111' ; GGG0BBBB
405 movwf aa_colorDiv+1,ACCESS 329 movwf aa_temp+1,ACCESS
406 330
407 btfss aa_color_half,ACCESS 331 btfss aa_color_half,ACCESS
408 bra aa_decode_12 332 bra aa_decode_12
409 333
410 movff aa_colorDiv+0,PRODH ; Add color/2 if bit set. 334 movff aa_temp+0,PRODH ; Add color/2 if bit set.
411 movff aa_colorDiv+1,PRODL ; OLED is big endian, so swap here. 335 movff aa_temp+1,PRODL ; OLED is big endian, so swap here.
412 aa_decode_12: 336 aa_decode_12:
413 btfss aa_color_quart,ACCESS 337 btfss aa_color_quart,ACCESS
414 bra aa_decode_3 338 bra aa_decode_3
415 339
416 ; Divide it once again by 2. Max red = 7/31. 340 ; Divide it once again by 2. Max red = 7/31.
417 rrcf aa_colorDiv+0,W,ACCESS ; xxRRRxxG 341 rrcf aa_temp+0,W,ACCESS ; xxRRRxxG
418 andlw b'00111001' ; 00RRR00G (don't change C) 342 andlw b'00111001' ; 00RRR00G (don't change C)
419 movwf aa_colorDiv+0,ACCESS 343 movwf aa_temp+0,ACCESS
420 rrcf aa_colorDiv+1,W,ACCESS ; GGGxxBBB 344 rrcf aa_temp+1,W,ACCESS ; GGGxxBBB
421 andlw b'11100111' ; GGG00BBB 345 andlw b'11100111' ; GGG00BBB
422 movwf aa_colorDiv+1,ACCESS 346 movwf aa_temp+1,ACCESS
423 347
424 movf aa_colorDiv+1,W,ACCESS ; Add color/4 348 movf aa_temp+1,W,ACCESS ; Add color/4
425 addwf PRODL,F ; NOTE: 7/31+15/31=22/31, 349 addwf PRODL,F ; NOTE: 7/31+15/31=22/31,
426 movf aa_colorDiv+0,W,ACCESS ; hence composants won't overlap. 350 movf aa_temp+0,W,ACCESS ; hence composants won't overlap.
427 addwfc PRODH,F ; In right order, to propagate carry. 351 addwfc PRODH,F ; In right order, to propagate carry.
428 352
429 bra aa_decode_3 ; Done. 353 bra aa_decode_3 ; Done.
430 354
431 ; ---- Simple BLACK and WHITE cases ------------------------------ 355 ; ---- Simple BLACK and WHITE cases ------------------------------
468 aa_wordprocessor: 392 aa_wordprocessor:
469 ; Make sure context is well known 393 ; Make sure context is well known
470 movlb HIGH win_top ; Switch to bank 0... 394 movlb HIGH win_top ; Switch to bank 0...
471 395
472 rcall aa_string_width ; Set win_height, compute win_width 396 rcall aa_string_width ; Set win_height, compute win_width
473 rcall aa_box_cmd ; Use that for the box. 397 rcall PLED_box_write ; Use that for the box.
474 398
475 ; Restart the loop for each char to print 399 ; Restart the loop for each char to print
476 lfsr FSR2, letter ; FSR2 pointer to start of string. 400 lfsr FSR2, letter ; FSR2 pointer to start of string.
477 401
478 ; DATA bloc commande: 402 ; DATA bloc commande: