/[projet1]/users/coco/oruidic/rout_text.s
Defence Force logotype

Contents of /users/coco/oruidic/rout_text.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 374 - (show annotations)
Mon Aug 9 21:35:33 2010 UTC (9 years, 9 months ago) by coco
File size: 3852 byte(s)
- Routine d'affichage de texte en TEXT 
1 ;
2 ; -------------------------------------------------------------------
3 ; This is a simple display module
4 ; called by the C part of the program
5 ; We define the adress of the TEXT screen.
6 ;
7 #define DISPLAY_ADRESS $BB80
8 ;
9 ; We use a table of bytes to avoid the multiplication
10 ; by 40. We could have used a multiplication routine
11 ; but introducing table accessing is not a bad thing.
12 ; In order to speed up things, we precompute the real
13 ; adress of each start of line. Each table takes only
14 ; 28 bytes, even if it looks impressive at first glance.
15 ;
16 ; This table contains lower 8 bits of the adress
17 TextAdressLow
18 .byt <(DISPLAY_ADRESS+40*0)
19 .byt <(DISPLAY_ADRESS+40*1)
20 .byt <(DISPLAY_ADRESS+40*2)
21 .byt <(DISPLAY_ADRESS+40*3)
22 .byt <(DISPLAY_ADRESS+40*4)
23 .byt <(DISPLAY_ADRESS+40*5)
24 .byt <(DISPLAY_ADRESS+40*6)
25 .byt <(DISPLAY_ADRESS+40*7)
26 .byt <(DISPLAY_ADRESS+40*8)
27 .byt <(DISPLAY_ADRESS+40*9)
28 .byt <(DISPLAY_ADRESS+40*10)
29 .byt <(DISPLAY_ADRESS+40*11)
30 .byt <(DISPLAY_ADRESS+40*12)
31 .byt <(DISPLAY_ADRESS+40*13)
32 .byt <(DISPLAY_ADRESS+40*14)
33 .byt <(DISPLAY_ADRESS+40*15)
34 .byt <(DISPLAY_ADRESS+40*16)
35 .byt <(DISPLAY_ADRESS+40*17)
36 .byt <(DISPLAY_ADRESS+40*18)
37 .byt <(DISPLAY_ADRESS+40*19)
38 .byt <(DISPLAY_ADRESS+40*20)
39 .byt <(DISPLAY_ADRESS+40*21)
40 .byt <(DISPLAY_ADRESS+40*22)
41 .byt <(DISPLAY_ADRESS+40*23)
42 .byt <(DISPLAY_ADRESS+40*24)
43 .byt <(DISPLAY_ADRESS+40*25)
44 .byt <(DISPLAY_ADRESS+40*26)
45 .byt <(DISPLAY_ADRESS+40*27)
46
47 ; This table contains hight 8 bits of the adress
48 TextAdressHigh
49 .byt >(DISPLAY_ADRESS+40*0)
50 .byt >(DISPLAY_ADRESS+40*1)
51 .byt >(DISPLAY_ADRESS+40*2)
52 .byt >(DISPLAY_ADRESS+40*3)
53 .byt >(DISPLAY_ADRESS+40*4)
54 .byt >(DISPLAY_ADRESS+40*5)
55 .byt >(DISPLAY_ADRESS+40*6)
56 .byt >(DISPLAY_ADRESS+40*7)
57 .byt >(DISPLAY_ADRESS+40*8)
58 .byt >(DISPLAY_ADRESS+40*9)
59 .byt >(DISPLAY_ADRESS+40*10)
60 .byt >(DISPLAY_ADRESS+40*11)
61 .byt >(DISPLAY_ADRESS+40*12)
62 .byt >(DISPLAY_ADRESS+40*13)
63 .byt >(DISPLAY_ADRESS+40*14)
64 .byt >(DISPLAY_ADRESS+40*15)
65 .byt >(DISPLAY_ADRESS+40*16)
66 .byt >(DISPLAY_ADRESS+40*17)
67 .byt >(DISPLAY_ADRESS+40*18)
68 .byt >(DISPLAY_ADRESS+40*19)
69 .byt >(DISPLAY_ADRESS+40*20)
70 .byt >(DISPLAY_ADRESS+40*21)
71 .byt >(DISPLAY_ADRESS+40*22)
72 .byt >(DISPLAY_ADRESS+40*23)
73 .byt >(DISPLAY_ADRESS+40*24)
74 .byt >(DISPLAY_ADRESS+40*25)
75 .byt >(DISPLAY_ADRESS+40*26)
76 .byt >(DISPLAY_ADRESS+40*27)
77
78 ;
79 ; The message and display position will be read from the stack.
80 ; sp+0 => X coordinate
81 ; sp+2 => Y coordinate
82 ; sp+4 => Adress of the message to display
83 ;
84 _TextPlot
85 ; Initialise display adress
86 ; this uses self-modifying code
87 ; (the $0123 is replaced by display adress)
88 ; The idea is to get the Y position from the stack,
89 ; and use it as an index in the two adress tables.
90 ; We also need to add the value of the X position,
91 ; also taken from the stack to the resulting value.
92
93 ldy #2
94 lda (sp),y ; Access Y coordinate
95 tax
96 lda TextAdressLow,x ; Get the LOW part of the screen adress
97 clc ; Clear the carry (because we will do an addition after)
98 ldy #0
99 adc (sp),y ; Add X coordinate
100 sta textplotwrite+1
101 lda TextAdressHigh,x ; Get the HIGH part of the screen adress
102 adc #0 ; Eventually add the carry to complete the 16 bits addition
103 sta textplotwrite+2
104 ; Initialise message adress using the stack parameter
105 ; this uses self-modifying code
106 ; (the $0123 is replaced by message adress)
107 ldy #4
108 lda (sp),y
109 sta textplotread+1
110 iny
111 lda (sp),y
112 sta textplotread+2
113 ; Start at the first character
114 ldx #0
115 textplot_loop
116 ; Read the character, exit if it's a 0
117 textplotread
118 lda $0123,x
119 beq textplot_end
120 ; Write the character on screen
121 textplotwrite
122 sta $0123,x
123 ; Next character, and loop
124 inx
125 jmp textplot_loop
126 ; Finished !
127 textplot_end
128 rts
129
130

  ViewVC Help
Powered by ViewVC 1.1.26