Adventurer #08
31 августа 1998 |
|
Exchange of experience - Art Studio and the principle of open architecture (how to write their own modules to the editor).
(C) Ivan Roshchin, Moscow, 1998 ART STUDIO and the principle of open architecture There exists a version of the graphical editor ART STUDIO (v2.01c, corrected by ROM / SM and FUX / SM), which can play music while working. T. is, the disk contains the editor, and immediately after him - the file "artmusic", containing compiled music format PRO TRACKER or SOUND TRACKER PRO. When you run the editor, this file is loaded into free bank of RAM (1 or 6), and in the process calls the player 'and to interrupts. (It turned out that the name of the file does not matter, if only he was written directly to the editor ie, the file "ART ".) I used to use other versions of ART STUDIO, who had his drawbacks: the needle will disappear is not clear which then appear on the screen colored bands, and all hang ... So with the advent of the new version, I turned to her. But even here I waited for the unpleasant features (in general, known to all users ART STUDIO) - inclusion of a white border 'and modes Magnify, Font editor and Scrapbook. You should have something to do with it, and I decided to slightly change the player in a file with the music. Editor installed white border, but caused an interrupt player, in addition to its main tasks, set me right color. Quite a long time I have worked with such version of ART STUDIO, has not yet emerged Another problem: it was necessary to draw some image from the known coordinates of its points. How, for example, noted in the figure the point with coordinates X = 45, Y = 83? Now, if the screen constantly displays the current coordinates cursor ... And then I thought: what if I write module with the same start address (# C000), the same entry points (INIT = # C000, PLAY = # C006), as compiled from the music, and then "sneak" him editor, writing the file instead "Artmusic". And this module, in turn, each time when his appeal is to be displayed on the screen coordinates of the cursor. Module (aka art_xy) was written and a successful conclusion coordinates (and besides, watching the border 'th and I installed the necessary initial values of attributes). At the end of this article provides the source code of its principal part, which will come in handy when developing own modules. What do we see? It turns out that any missing an opportunity to ART STUDIO easy to implement yourself by writing for This special module. And if it is written several modules, you can download them in turn, without leaving the editor (for Then, of course, each module must be provided for the team - download another module and give him control). RAM DISK ART STUDIO Module 1 ... Module 1 Module n Create your own module, without a doubt, much easier than writing a new graphical editor from scratch. Different modules can be written by different people, independently of each other. And therein lies the principle of open architecture. Surely James Hutchby, author ART STUDIO, had no idea about such features of its editor. What functions can be contained in additional module? For example, fast Viewing images recorded on the disc without download them to the editor, saving and recovery configuration, use more memory (> 128K) as RAM - disk, perform various transformations on the marked the window well and Of course, music, and screen saver. All this quite fit in 16 kilobytes. In the "ZX-FORMAT # 7" You can read about project, "STATE OF THE ART" group "AVALON". As written there is a new graphics editor with extraordinary capabilities, combining the advantages the best editors on SPECTRUM, PC and AMIGA. I wish that there used modular construction, with detailed description of the interface between the module and the editor, so that each user himself may realize the desired him function. It gives almost unlimited expansion possibilities editor. Now I'll discuss in more detail how to write your own module ART STUDIO. I'll start with I have known addresses, which are variables Editor: INK - 52186 (0-7, 8-transp.) PAPER - 52,187 (0-7, 8-transp.) BORDER - 52,188 (0-7) BRIGHT - 52189 (0-off, one-on, two-transp.) FLASH - 52190 (0-off, one-on, two-transp.) The absolute coordinates of the cursor (X - 56035, Y - 56,036) duplicated addresses 64977 and 64978, respectively. Home coordinates located in the upper left corner of the screen. Since these variables are in 0 memory bank, and the module is loaded into a or 6 bank is accessed with using special functions - see listing. During the first 50 calls to the module (ie, 1 second of real time After starting the editor) unpacking editor and initialize variables. If the module required to change a set of default attributes (INK, PAPER, BORDER) on the other - these attributes needed to reinstall when Each of the first 50 hits. Explanation here is: Obviously, when you start the editor commands are executed the following: LD A, 0 LD (52186), A; INK LD A, 7 LD (52187), A; PAPER LD A, 7 LD (52188), A; BORDER ... , An interrupt occurs, causing , With a module that installs ; Necessary INK, PAPER, BORDER CALL CLS; clear screen , Acc. attributes It is evident that the installation of the necessary attributes to occur after the editor of these settings, but prior to as an editor to clean up the screen. A since it is unknown which of the account termination will match this moment, prihoditrya perform the installation attributes of 50. By the way, if you run the editor need to change the default values for attributes on the "transparent", it is better to do after the first 50 calls module - otherwise the screen during the cleaning attributes of familiarity will be established at random manner. Source the main part of the module "art_xy" ORG # C000 JP INIT; # C000 - INIT DS 3 JP PLAY; # C006 - PLAY RET; # C009 - STOP ; Values INK, PAPER, BORDER: COLORS DB 7,0,0 ;--------------------------------------; Procedure INIT - executed before ; The beginning of the editor. INIT DI ; Save memory for the resident: CALL SAVE_M ; We transfer a resident of N3, and run it. In cells BANK obtain bank number, , Which is loaded art_xy: LD HL, RES3_B CALL LOAD_R CALL # 6000 ; Restore previously saved ; Chunk by a resident: CALL LOAD_M ; Display a message "module is loaded ..." , And the expectation of keystrokes: CALL # D000 INIT1 XOR A IN A, (254) CPL AND 31 JR Z, INIT1 EI RET ;--------------------------------------; Procedure PLAY - performed every , 1 / 50 seconds. PLAY DI CALL SAVE_M ... CALL LOAD_M EI RET ;--------------------------------------; Procedure LOAD_M stored in a buffer ; The memory under the resident ; (Start address - # 6000, the length of the - The length of the longest resident in the ; This module is a resident of N3). LOAD_M LD HL, RES_BUF LOAD_R LD DE, # 6000 LD BC, RES3_E-RES3_B LDIR RET ;--------------------------------------; SAVE_M procedure restores the previously ; Memorized (with LOAD_M) plot ; Memory. SAVE_M LD HL, # 6000 LD DE, RES_BUF LD BC, RES3_E-RES3_B LDIR RET ;--------------------------------------; Procedure GET_MEM - analog command ; LD A, (DE). Need for access to bank 0 ; Memory. GET_MEM PUSH HL PUSH BC PUSH DE LD HL, RES1_B CALL LOAD_R POP DE CALL # 6000 POP BC POP HL RET ;--------------------------------------; Procedure TO_MEM - analog command ; LD (DE), A. Need for access to bank 0 ; Memory. TO_MEM PUSH HL PUSH BC PUSH DE LD HL, RES2_B CALL LOAD_R POP DE CALL # 6000 POP BC POP HL RET ;--------------------------------------; Resident N1 - LD A, (DE): RES1_B LD BC, # 7FFD LD HL, (BANK) OUT (C), H LD A, (DE) OUT (C), L RET RES1_E ;--------------------------------------; Resident N2 - LD (DE), A: RES2_B LD BC, # 7FFD LD HL, (BANK) OUT (C), H LD (DE), A OUT (C), L RET RES2_E ;-------------------------------------; Resident N3 determines which bank , (1 or 6) module is loaded art_xy. ; Record this value in the variable ; BANK. RES3_B LD BC, # 7FFD LD A, # 11 OUT (C), A LD A, (PRIZN) CP "+" LD A, # 11 JR Z, RES3_1 LD A, # 16 RES3_1 OUT (C), A LD (BANK), A RET RES3_E ;--------------------------------------; Dl buffer memory of the memory ; A resident: RES_BUF DS RES3_E-RES3_B PRIZN DB "+" BANK DW # 1000
Other articles:
Similar articles:
В этот день... 23 November