# mitallast/diablo-js architecture

> Architecture diagram of the GitHub repository mitallast/diablo-js, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mitallast/diablo-js
- Repository: https://github.com/mitallast/diablo-js

## Overview

##### Main Components

A. Resource Extraction Layer
- DTTool Component (Java-based)
- DS1 Parser (level data)
- DT1 Parser (tile data)
- Palette Reader
- ShadowMaker Component (Java-based)
- Shadow calculation for sprites

B. Asset Management Layer
- Texture Management
- Monster Sprites
- Level Data
- Palette Data

C. Game Engine Layer (JavaScript)
- Renderer Component
- Isometric View Handler
- Canvas Management
- System
- Layer Management (walls, floors, objects)
- Input Handler
- Tab key for map toggle

D. Web Interface
- HTML5 Canvas
- JavaScript Runtime

- [DTTool] -----> [Processed Assets]
- [ShadowMaker] -> [Processed Sprites]

- [Textures] [Sprites] [Level Data] [Palettes]
- /
- /
- /
- [Asset Management System]

- [Game Engine (diablo.js)]

- [HTML5 Canvas Renderer]

##### Important Relationships

- Data flow from original Diablo 2 assets through DTTool to processed assets
- Sprite processing pipeline through ShadowMaker
- Asset loading path into the game engine
- Rendering pipeline from game engine to canvas

##### Technical Details

- File format transformations (DS1, DT1, PL2)
- Asset organization structure (ACT1-5 folders)
- Monster sprite categories (BA, FS, SI, SK)
- Shadow processing workflow

##### Implementation Notes

- The separation between asset processing tools and runtime engine
- The isometric rendering system
- The layer-based map system
- Asset management and loading pipeline

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Asset Processing Tools"
        DT[DTTool]
        SM[ShadowMaker]
        
        subgraph "DTTool Components"
            DS["DS1 Parser"]
            DTP["DT1 Parser"]
            PR["Palette Reader"]
        end
        
        DT --> DS
        DT --> DTP
        DT --> PR
    end
    
    subgraph "Asset Management"
        TM["Texture Storage"]
        MS["Monster Sprites"]
        LD["Level Data"]
        PD["Palette Data"]
        
        subgraph "Monster Categories"
            BA["Barbarian"]
            FS["Forsaken"]
            SK["Skeleton"]
            SI["Siren"]
        end
        
        MS --> BA
        MS --> FS
        MS --> SK
        MS --> SI
    end
    
    subgraph "Game Engine Layer"
        GE["Game Engine"]
        
        subgraph "Renderer"
            ISO["Isometric View"]
            CM["Canvas Management"]
        end
        
        subgraph "Map System"
            LM["Layer Management"]
        end
        
        GE --> ISO
        GE --> CM
        GE --> LM
    end
    
    subgraph "Web Interface"
        WI["HTML5 Canvas"]
    end
    
    DT --> TM
    DT --> LD
    DT --> PD
    SM --> MS
    
    TM --> GE
    MS --> GE
    LD --> GE
    PD --> GE
    
    GE --> WI
    
    %% Click Events
    click GE "https://github.com/mitallast/diablo-js/blob/master/diablo.js"
    click WI "https://github.com/mitallast/diablo-js/blob/master/index.html"
    click DS "https://github.com/mitallast/diablo-js/blob/master/dttool/src/main/org/mitallast/ds1/DsReader.java"
    click DTP "https://github.com/mitallast/diablo-js/blob/master/dttool/src/main/org/mitallast/dt1/DtReader.java"
    click PR "https://github.com/mitallast/diablo-js/blob/master/dttool/src/main/org/mitallast/pallete/PaletteReader.java"
    click SM "https://github.com/mitallast/diablo-js/blob/master/shadowmaker/src/main/java/org/mitallast/ShadowMaker.java"
    click TM "https://github.com/mitallast/diablo-js/tree/master/texture"
    click MS "https://github.com/mitallast/diablo-js/tree/master/monsters"
    click LD "https://github.com/mitallast/diablo-js/tree/master/dttool/tiles"
    click PD "https://github.com/mitallast/diablo-js/tree/master/dttool/palette"
    click BA "https://github.com/mitallast/diablo-js/tree/master/monsters/BA"
    click FS "https://github.com/mitallast/diablo-js/tree/master/monsters/FS"
    click SK "https://github.com/mitallast/diablo-js/tree/master/monsters/SK"
    click SI "https://github.com/mitallast/diablo-js/tree/master/monsters/SI"
    
    %% Styling
    classDef tools fill:#2374ab
    classDef assets fill:#57a773
    classDef runtime fill:#ff8c42
    classDef ui fill:#9b5de5
    
    class DT,SM,DS,DTP,PR tools
    class TM,MS,LD,PD,BA,FS,SK,SI assets
    class GE,ISO,CM,LM runtime
    class WI ui
    
    %% Legend
    subgraph Legend
        L1["Asset Processing Tools"]:::tools
        L2["Asset Storage"]:::assets
        L3["Runtime Components"]:::runtime
        L4["User Interface"]:::ui
    end
```
